Load value in a date form field

Hi!I think it's easy but for some reason what I want to do is not working. When I call to the new method I do that before render the new.html.erb page:

@cambio = Cambio.new @cambio.user_id_origen = current_user.id @cambio.start_date = current_user.date

Debuggin with Aptana I've seen that @cambio.start_date gets the correct value, but when the html page renders it can't fill the form field with that value. Anybody knows how can I do that?

Thanks in advance.

What does your new.html.erb look like?

It depends of the type of field you are using when trying to display the value.

Serge

sergecpelletier wrote:

What does your new.html.erb look like?

It depends of the type of field you are using when trying to display the value.

Serge

On Apr 18, 8:13 pm, "Daniel A." <rails-mailing-l...@andreas-s.net>

<h1>New cambios</h1>

<%= error_messages_for :cambios %>

<% form_for(@cambios) do |f| %>   <p>     <!--<b>User id origen</b><br />-->     <%= f.text_field :user_id_origen %>   </p>

  <p>     <b>Fecha origen</b><br />     <%= f.date_select :fecha_origen %>   </p>

  <p>     <%= f.submit "Create" %>   </p> <% end %>

<%= link_to 'Back', cambios_path %>

&lt;b&gt;Fecha origen&lt;/b&gt;&lt;br /&gt;
&lt;%= f\.date\_select :fecha\_origen %&gt;

Shouldn't this be f.date_select :start_date ?

(Yes, start_date unless it's been translated for our English-speaking group).

Also, it appears that you are using @cambio (singular) in the controller and @cambios (plural) in the form_for of the view.