Setting default value in text_field/password_field

I am trying to set a default value in a text_field form. I know how
to do this in html, but is there a way to do
this with form_for

Here is my code

<% form_for :user do |f| -%>

<p><label for="firstname"%>First Name</label><br/>
<%= f.text_field :firstname%></p>
<p><label for ="email"%>Email</label><br/>
<%=f.text_field :email %></p>

<p><label for="password"%>Password</label><br/>
<%=f.password_field :password %></p>
<p><%= submit_tab 'Sign up' %></p>
<% end -%>

I would like to produce something of this type for both text_field and
<input type="text" name = "email" value=""
Any ideas???

Hi, you should be able to do the following as stated in the Rails Framework Documentation:

<%= f.text_field :email, options => { :value => “” } %>

Good luck,


The initial values will be taken from @user, so populate that
(typically in the controller) before rendering your template.

   @user = = "")
   ... then render the template