Forum: Ruby on Rails How can I set default value for text_field?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Zhao Y. (Guest)
on 2008-11-30 13:19
Please this code:

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

I want to set a default to this text field, how can I do this?
Petan C. (Guest)
on 2008-11-30 15:42
Zhao Yi wrote:
> Please this code:
>
> <p>
>     <%= f.label :"Host Name" %><br />
>     <%= f.text_field :HostName %>
> </p>
>
> 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" %>
Zhao Y. (Guest)
on 2008-12-01 02:47
Petan C. wrote:
> Zhao Yi wrote:
>> Please this code:
>>
>> <p>
>>     <%= f.label :"Host Name" %><br />
>>     <%= f.text_field :HostName %>
>> </p>
>>
>> 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.
This topic is locked and can not be replied to.