Be careful with .select

ioev Sep 12, 2014

With 999 people in the table:

Person.select('person.firstname').find_in_batches do |group|
group.each { |person| puts person.firstname }
end

Will work properly.

But with 1001 people in the table, this will raise "Primary key not included in the custom select clause". It's a bit of a...

This method does not correctly dup arrays

danielglh Aug 25, 2014 1 thank

Watch out because this method does not correctly dup arrays values.

The bug can be reproduced with the following code:

hash = { 'a' => [1,2,3,4] }
dup  = hash.deep_dup
dup['a'].object_id == hash['a'].object_id # should return true

Rails 4 version does not have this issue because it is...

Non-existent key semantics changed.

matthewtuck Aug 13, 2014

For Rails 4.0, the behaviour of this has changed when you pass a key that isn't in the hash.

3.2 (undocumented):

{ a: 1, b: 2 }.extract!(:a, :x) # => {:a=>1, :x => nil}

4.0 (as per docs):

{ a: 1, b: 2 }.extract!(:a, :x) # => {:a=>1}

The 4.0 behaviour is now consistent with the behaviour...

simple use

Milind Aug 5, 2014

Examples

<%= @user.created_at.to_date.to_formatted_s(:long_ordinal)%> => July 5th, 2014

==OR

<%[email protected]_at.strftime("%b %d,%Y") %> =>  Jul 05,2014

===quick ref:- :db # => 2008-12-25 14:35:05 :number # => 20081225143505 :time # => 14:35 :sh...