views:

36

answers:

2

I use form_for to save a model object site

<% form_for :site :url => {:controller => 'site', :action => 'add_site' } do |f| -%>

          <%= f.text_field :protocol, :size => 127, :style => 'width:255px' , :value => "http://"%&gt;
          <%= f.text_field :site_name, :size => 127, :style => 'width:255px' , :value => "www."%>

        <%= f.hidden_field :user_id, :value => @user.id %>
        <%= f.hidden_field :status, :value => 'Not Verified' %>

<% end -%>

here the field protocol is not a instance of the model site. but i just want to pass to the action add_site so that i can use as params[:protocol]

what should i do to achieve this?

+1  A: 

Add it to your site model as an attribute accessor:

attr_accessor :protocol

See http://railscasts.com/episodes/16-virtual-attributes .

mark
+2  A: 

You can set something like this:

<%= text_field_tag :protocol %>

To the action of the controller you can refer to this as params[:protocol]

JohnDel