Living on the edge (of Rails) #10

In: Edge Rails|Open Source|Ruby|Ruby on Rails

5 Mar 2008

Another awfully sleepy week on Rails edge. Though by the time I had sent over the notes to Gregg Pollack and Jason Seifer of the awesome Rails Envy podcast, there has been some nice changes (that I’ll be mentioning next week, but there’s absolutely nothing stopping you from checking those out yourself).

In other interesting news, Pratik Naik (lifofifo), a long-time Rails contributor has been given commit rights to Rails. Congrats Pratik, well-deserved and it has been long overdue in my opinion! Pratik keeps an interesting blog at http://m.onkey.org/ (where he’s not afraid to say “fuck” in his posts and his code) and hangs out an awful lot on #rubyonrails and #rails-contrib on IRC.

As a sidenote, Capistrano 2.2.0 was released by Jamis last week.

This week’s report covers changes from 25 Feb 2008 to 2 Mar 2008 (the day the corresponding Rails Envy podcast was recorded).

Time#end_of_XXX methods

A bunch of Time core extension methods have been added. These are: Time#end_of_day, Time#end_of_week, Time#end_of_year, and Time#end_of_quarter, which all return exactly what you expect them to return:

Time.now.end_of_week # => Sun Mar 09 00:00:00 0800 2008

Credit goes to Juanjo Bazán (a former Rails Hackfest winner) and Tarmo Tänav for contributing this patch.

Related changeset: http://dev.rubyonrails.org/changeset/8934

Date helpers now accept HTML options

ActionView’s date helpers (such as date_select, time_select, select_datetime) did not support any HTML options, unlike the other helpers (like f.text_field(:name, :class => 'my_css_class', :size => 20)). This inconsistency has been fixed and you can now finally do:

<%= date_select 'user', 'birthday', :order => [:day], :class => 'my_css_class' %>

Murray Steele (h-lame on the Rails Trac) and Jakob Skjerning contributed this patch.

Related changeset: http://dev.rubyonrails.org/changeset/8968

No need for explicit respond_to for RJS templates

ActionController has been changed so that JS requests will automatically render action.js.rjs files without the need to specify an explicit respond_to block. This means that your .rjs files work the same way as your .html.erb files – just put them in the right place and Rails will use it.

Related changeset: http://dev.rubyonrails.org/changeset/8956

Bugfixes

  • http://dev.rubyonrails.org/changeset/8937 – Prevent Rails from crashing when trying to deserialize an XML representation of a model named “Type” (using Hash#from_xml). Contributed by Juanjo Bazán and Isaac Feliu.
  • http://dev.rubyonrails.org/changeset/8942 – Fix eager loading so that it doesn’t pull in duplicate records in some cases. Contributed by Catfish.

As usual, let me know of any inaccuracies or any suggestions you may have in the comments!

3 Responses to Living on the edge (of Rails) #10

Avatar

choonkeat

March 6th, 2008 at 12am

Finally!! [8956] had been pointed out and requested for minutes after the “respond_to” debut in RailsConf ’06!!!

Avatar

A Fresh Cup » Blog Archive » Double Shot #159

March 6th, 2008 at 7pm

[…] Living on the edge (of Rails) #10 – Looks like it’s been another quiet week out at the edge. […]

Avatar

David

March 7th, 2008 at 8am

[8956] — No need for explicit respond_to for RJS templates — might be useful if you’re passing javascript/json back and forth, but if you were trying to get a chunk of rendered HTML, you’ll have to make some changes.

The solution is just to add a parameter to your javascript, passing the parameter “format=html”. In prototype xhr, that’s:
parameters: 'format=html'

I kept trying to fix this on the rails side and for some reason it wasn’t responding.