I have this is my new form:
<table>
<tr>
<th><%= _('Sales date') %></th>
</tr>
<tr>
<td> <%= f.datetime_select :sales_date %></td>
</tr>
</table>
With this code I’m showing year, month, day and hour. I only want to
show year and month. How can I do that?
Try:
<%= f.date_select(:sales_date, :discard_day => 1) %>
Eric
RoR Power
http://www.rorpower.com
John S. wrote:
I have this is my new form:
<table>
<tr>
<th><%= _('Sales date') %></th>
</tr>
<tr>
<td> <%= f.datetime_select :sales_date %></td>
</tr>
</table>
With this code I’m showing year, month, day and hour. I only want to
show year and month. How can I do that?
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] %>
On Sun, Mar 30, 2008 at 8:24 PM, John S. <
[email protected]> wrote:
–
Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
And how can I do that?
I have:
<table >
<tr>
<th><%= _('Sales date') %></th>
</tr>
<tr>
<td><%=h @ticket.sales_date.to_s(:short)%> </td>
</tr>
</table>
It shows day, month and hour. I want it to show day and month
Day month and year you mean?
@ticket.sales_date.strftime("%m-%Y")
On Sun, Mar 30, 2008 at 8:57 PM, John S. <
[email protected]> wrote:
<td><%=h @ticket.sales_date.to_s(:short)%> </td>
</tr>
It shows day, month and hour. I want it to show day and month
Posted via http://www.ruby-forum.com/.
–
Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
Ryan B. wrote:
Day month and year you mean?
@ticket.sales_date.strftime("%m-%Y")
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.
On Sun, Mar 30, 2008 at 9:04 PM, John S. <
[email protected]> wrote:
Posted via http://www.ruby-forum.com/.
–
Ryan B.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
Look up the API for the datetime_select helper.
http://api.rubyonrails.org/
Julian.
environment.rb
Time::DATE_FORMATS[:special] = “%m-%Y”
/app/views/any_view.html.erb
<%=h @ticket.sales_date.to_s(:special)%> |