Ruby on rails 如何在rails中使用表单_发送与模型对象不关联的参数
我使用表单_保存模型对象Ruby on rails 如何在rails中使用表单_发送与模型对象不关联的参数,ruby-on-rails,Ruby On Rails,我使用表单_保存模型对象site <% form_for :site :url => {:controller => 'site', :action => 'add_site' } do |f| -%> <%= f.text_field :protocol, :size => 127, :style => 'width:255px' , :value => "http://"%> <%=
site
<% form_for :site :url => {:controller => 'site', :action => 'add_site' } do |f| -%>
<%= f.text_field :protocol, :size => 127, :style => 'width:255px' , :value => "http://"%>
<%= 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 -%>
{:controller=>'site',:action=>'add|u site'}do | f |-%%>
127,:style=>width:255px',:value=>http://“%>
127,:style=>width:255px',:value=>www.“%>
@user.id%>
'未验证'%>
此处,现场协议不是模型站点的实例。但是我只想传递到action add_站点,这样我就可以使用as params[:protocol]
我应该如何实现这一点?将其作为属性访问器添加到站点模型中:
attr_accessor :protocol
看 您可以设置如下内容:
<%= text_field_tag :protocol %>
对于控制器的操作,您可以将其称为params[:protocol]