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

On Apr 18, 8:13 pm, “Daniel A.” [email protected]

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.” [email protected]

New cambios

<%= error_messages_for :cambios %>

<% form_for(@cambios) do |f| %>

<%= f.text_field :user_id_origen %>

Fecha origen
<%= f.date_select :fecha_origen %>

<%= f.submit "Create" %>

<% end %>

<%= link_to ‘Back’, cambios_path %>

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

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.

On Apr 20, 9:26 am, Jan-Christian F. [email protected]