Tag: 隐藏字段

Rails:form_for中的隐藏字段不向控制器发送参数

我有一个form_for我在我的视图助手中制作,这将让一个用户从一个组中提升另一个用户。 def promote_button_for(group, user) membership = group.get_membership( user ) form_for membership, :url => group_membership_path( group, membership ) do |f| f.hidden_field :group_creator hidden_field_tag ‘test’, ‘1’ f.submit( “Promote”, :onclick => “return confirm(\”Are you sure you want to promote #{user.email} to an officer?\”)” ) end end 当我通过按钮提交表单时,我似乎没有将任何隐藏的字段参数发送到控制器。 Started POST “/groups/1/memberships/6” for 127.0.0.1 at 2011-02-01 01:45:32 -0600 Processing by […]

Rails 3:为什么空的嵌套表单会生成隐藏的输入字段?

为什么这个: # edit.html.erb # Nothing here 生成隐藏的输入字段: ? 相关控制器代码: def edit @product = Product.find(params[:id]) end

在嵌套模型轨道中传递数组隐藏字段

我在视图中有以下代码: 30 %> 在控制台中传递的参数 Parameters: {“authenticity_token”=>”LJ/ZME2lHZ7VwCDgPKX6OFe326fXSXo5UB4M0cPwbCE=”, “esthour”=>{“rfp_id”=>”6”, “ecommerce_est_hours”=>””, “modul1hours”=>{“module_est_hours”=>”3”}, “designpages_est_hours”=>””, “cms_est_hours”=>””}, “modul1_ids”=>[“12”, “13”, “14”], “utf8″=>”✓”, “project_id”=>”second”, “commit”=>”Add Todo”} 当前用户:admin(id = 1) modul1_ids是基于创建三个文本框的隐藏数组,但是当我提交页面时,我给出了: ActionView::Template::Error (undefined method `merge’ for 12:Fixnum): 在第一个文本框中,我通过1秒2和第三个3 最后一个值(3)是一个人可以在控制台中看到的参数params module_est_hours”=>”3 ,但是rest的两个字段y没有通过什么,并且解决了错误的解决方案。 请帮我。 编辑1 30 %> 此代码不会给出错误,但值也不会存储在modul1hours表中 modul1hours表的字段是: integer :modul1_id decimal :module_est_hours decimal :module_act_hours integer :esthours_id ] .RB belongs_to:esthour attr_accessible:module_est_hours,:module_act_hours 和控制器 更新 def new @esthour […]