Its all about Ruby On Rails
edge_rails
Edge Rails: Time#current
Jul 5th
Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now
Edge Rails: Array#random_element
May 24th
Array#rand is deprecated in favor of Array#random_element and will be removed in Rails 3.
As per the comment added to the commit:
Array#rand is deprecated because it masks Kernel#rand within the Array class itself, which may be used by a 3rd party library extending Array in turn. See https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555
Edge Rails Updates
May 14th
New edge rails deprecations:
Time#last_year is deprecated in favor of Time#prev_year
Time#last_month is deprecated in favor of Time#prev_month
Date#last_year is deprecated in favor of Date#prev_year
Date#last_month is deprecated in favor of Date#prev_month
New methods/aliases:
Date#sunday: Returns a new Date representing the end of this week
Time#sunday: Returns a new Time representing the end of this week
rename_index: Rename database index
Ex: rename_index :people, ‘index_people_on_last_name’, ‘index_users_on_last_name’
Feel free to add more as comments..
Edge rails: ActiveRecord::Base.each and ActiveRecord::Base.find_in_batches for batch processing
Feb 23rd
You guys must faced a situation when you need to process large number of records, for example sending newsletters. Then you must have done some sort of batch processing to save it eating up all of your memory. This feature is committed to rails core by DHH.
Now you can do something like User.each and User.find_in_batches.
Please refer here for more details.
Generating association while generating model
Dec 14th
May be you guys are already aware of, but in Rails 2.2 we can specify belongs_to association while generating model. So if we issue:
script/generate model Post title:string author:belongs_to
We will get a Post model like:
class Post < ActiveRecord::Base belongs_to :author end
Also it will automatically add the foreign key column in the migration.
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :title
t.belongs_to :author
t.timestamps
end
end
def self.down
drop_table :posts
end
end
Nothing much but saves some keystrokes.