I have this is my new form:
<th><%= _('Sales date') %></th>
<td> <%= f.datetime_select :sales_date %></td>
With this code I'm showing year, month, day and hour. I only want to
show year and month. How can I do that?
<%= f.date_select(:sales_date, :discard_day => 1) %>
Thnaks, it works! Now I obtain Year - Month. O would like to obtain
Month - Year. Is it possible?
You specify an additional option of :order
<%= f.date_select :sales_date, :discard_day => true, :order => [:month, :year] %>
Ryan Bigg wrote:
Day month and year you mean?
Thanks. I mean some kind of method, like :short. I need that because I'm
using Gettext with datetime objects.
.strftime is a method. You meant an argument. You’d have to change the way that ActiveSupport deals out the date formats for that. I don’t have the code on hand, sorry.
Look up the API for the datetime_select helper.
Time::DATE_FORMATS[:special] = "%m-%Y"
<td><%=h @ticket.sales_date.to_s(:special)%> </td>