Montag, 15. Juni 2009
Here's a tip on how to deal with with partial dates like hours with ruby on rails. start_hour in this example is a virtual attribute of the search model. To make the select_hour helper work properly, you need to add the the default value to use (@search.start_hour) as well as a prefix and field_name (this will tell rails how to name the field, 'search[start_hour]' in this case).

So, I assume you got some form declaration like this:
<% form_for(@search) do |f| %>

Now to add a hour select box inside that form, use code similar to this:
<%= select_hour @search.start_hour, :prefix => 'search', :field_name => 'start_hour' %>

This will also work with select_minute / select_second / select_day / select_month / select_year.