More Examples

waseem_ Feb 12, 2012 2 thanks

=== Code

class User < Struct.new(:name, :age, :gender) 
end

user = User.new("Matz", 43, "male")

Requires a Block.

joshuapinter Jan 30, 2012 2 thanks

Just a little heads up here because it's not obvious.

This requires a block to be passed to it.

==== Example Usage

say_with_time "Reverting all service rates to nil." do
Service.update_all( :rate, nil )
end

# Output
-- Reverting all service rates to nil.
 -> 0.345...

Example Usage

joshuapinter Jan 27, 2012

=== End of Day for Any Date

DateTime.new( 2011, 01, 01 )
# => Sat, 01 Jan 2011 00:00:00 +0000

DateTime.new( 2011, 01, 01 ).end_of_day
# => Sat, 01 Jan 2011 23:59:59 +0000

=== With Local Timezone

DateTime.civil_from_format( :local, 2011, 01, 01 ).end_of_day
# => Sat, 01 Ja...

Options

edivandecastro Jan 18, 2012

I came across the following situation An article has a history of friendly url being that the foreign key that represents the value of the article's id in the table is called Friend url_id then in that case:

Article.joins("INNER JOIN friends ON articles.id = friends.url_id").where("friends.url like...