KEEP IN TOUCH

Join Newsletter

CALL NOW

Share with:


Recent Posts





Jason Fleetwood-Boldt

The referrer is the URL the user came from. (It gets passed as part of the headers to the new request). You can get it out of rails this way: request.env['HTTP_REFERER'] Or the shorter version: request.referrer It seems that no one noticed that "referer" is actually not a word...

Read More

There are three ways to invoke a method. Most of the time you'll probably only need #1, but #2 and #3 are used when you are doing something called metaprogramming - calling methods based on dynamic information. 1. object = Object.new puts x.some_method #=> 282660 2. puts x.send(:some_method) #=> 282660 3....

Read More

Reads a file line by line into an array my_stuff my_stuff = [] file = File.new("config/random_categories.txt", "r") while (line = file.gets) my_stuff << line.chop! end file.close my_stuff Pass file to block File.open("my_file.rb", "r") do |infile| while (line = infile.gets) puts "#{counter}: #{line}" counter = counter + 1 end end Read File with Exception Handling counter = 1 begin file = File.new("readfile.rb", "r") while (line...

Read More

Note that when setting the Rails environment you have to pass it differently in different cases. For rake, set RAILS_ENV= as part of the command line options. rake db:migrate RAILS_ENV=test But when running script/console, you just put the environment name after the "script/console": script/console test ...

Read More

WARNING: These instructions are for Facebook version 1 (not Facebooker2). Since last year, I have moved toward using a different gem for this due to Facebooker's lack of documentation. Working on a new blog post detailing that. So you want to write a Facebook app...

Read More

This is a work in progress. Rails VersionRelease month 2.0.0Dec 2007 2.0.1Dec 2007 2.0.2Dec 2007 2.1.0May 2008 2.1.1Sept 2008 2.1.2Oct 2008 2.2.2Nov 2008 2.3.2March 09 2.3.3July 2009 2.3.4Sept 2009 2.3.5recently ...

Read More

strftime() turns a Date or DateTime into nicely formatted output. The following table shows the code you can use to create a nicely formatted date

>> x = DateTime.new(2009,9,5,15,45,50)
=> Sat, 05 Sep 2009 15:45:50 +0000

The default is %F which is the same as writing this.

>> x.strftime(‘%F’)
=> “2009-09-05”

Current timestamp with milliseconds.

#{DateTime.now.strftime(‘%Y-%m-%d %H:%M:%S + %L’)}

The is the very bare-bones basics of git.

First, I am staring by assuming that someone else has already setup a git repository on github. If it is a private repository, the author must grant you access to that repository by adding your github account name to the project.

Once this is done, you will see this project under “Your repositories.”

Every git project has a git URL associated with it. You will find this URL on the project’s page.