我正在使用表单,并且控制器中表单的名称显示为“#”,但我希望它显示为:edge。
这是我的控制器:
def new #some_stuff @edge = Edge.new #some_stuff end def create @edge = Edge.new(edge_params) @edge.save end def edge_params params.require(:edge).permit(:location_1_id, :location_2_id) end
视图:
<%= form_for( :edge, :url => {:action => 'create'}) do |f| %> <ul> <li> <%= f.label :location_1_id %> <%= collection_select(@edge, :location_1_id, @location, :id, :record_as_string) %> </li> <%= submit_tag(t(:create_edge)) %> </ul> <% end %>
参数要求:
{“ utf8” =>“✓”,“ authenticity_token” =>“ blah”,“#” => {“ location_1_id” =>“ 91”,“ location_2_id” =>“ 92”},“ commit” =>“创建边缘”,“操作” =>“创建”,“控制器” =>“管理员/边缘”,“ floor_map_floor_id” =>“ 1”}
因此参数的名称应为:edge,但这是我无法访问的对象。
谁能告诉我我所缺少的吗?任何帮助表示赞赏。