views:

22

answers:

1

I'm making a simplistic message board with tags. The message#index view displays a list of all messages. The tag#show view shows messages of a specified tag. On the message#index view, there is a form (partial) that requires the user to write a message and to tag it. On the tag#show view, I'd like to use the same form partial but to have the view's tag automatically filled into the form. In the show action of the tags controller, the name of the tag is @title.

The form partial looks like this:

<% form_for :message, :url => { :action => "create" }, :html => { :id => 'form' } do |f| %>
  <%= f.error_messages %>

  <%= f.label :tag, "tag<p2>( separate tags with a comma )</p2>" %>
  <%= f.text_field :tag_list %>

  <%= f.label :name, "name<p2>( optional )</p2>" %>
  <%= f.text_field :name %>

  <%= f.label :email, "email<p2>( optional )</p2>" %>
  <%= f.text_field :email %>

  <%= f.label :title, "message" %>
  <%= f.text_area :content %>

  <%= f.submit 'submit' %>
<% end %>

How do I auto fill the tag_list text field with the @title value? @title is a string. I appreciate any help you can offer. Thank you.

+4  A: 
<%= f.text_field :tag_list, :value => @title %>
Geoff Lanotte
Thanks, I knew it would be that simple!