I’m using Rails 3.0.5, and for the reasons specified in this question, I need to call a utc_to_local method on the text_field input for a datetime.
I’ve tried calling the method in various ways directly in the view (as a starting point), but I can’t seem to find the magic mix (haven’t called a method on a form field before).
/events/edit.html.erb (full file):
<h1>Edit This Event</h1>
<%= form_for(@event) do |f| %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Update Event" %>
</div>
<% end %>
events/_fields.html.erb (relevant lines only:)
<div class="field">
<%= f.label :time_start, "Start Time" %><br />
<%= f.text_field :time_start, :class => "datetimefield" %>
</div>
To answer straight:
But… why don’t you use
in_time_zone?Which would lead to the creation of an Application Helper:
And in your view: