How can I set default value for text_field?


#1

Please this code:

<%= f.label :"Host Name" %>
<%= f.text_field :HostName %>

I want to set a default to this text field, how can I do this?


#2

Zhao Yi wrote:

Please this code:

<%= f.label :"Host Name" %>
<%= f.text_field :HostName %>

I want to set a default to this text field, how can I do this?

Is this what you looking for?
<%= f.text_field :HostName, :value => “my default value” %>


#3

Petan C. wrote:

Zhao Yi wrote:

Please this code:

<%= f.label :"Host Name" %>
<%= f.text_field :HostName %>

I want to set a default to this text field, how can I do this?

Is this what you looking for?
<%= f.text_field :HostName, :value => “my default value” %>

Yes, this is exactly what I am looking for.

thanks.