我正在创建一个设备,我在我的设备控制器中有两个动作,new
和create
..我有两个视图,它们是新视图和部分视图。
我还有四个表.. equipments
,equipment_types
,equipment_locations
和equipment_management_informations
..
表单看起来像..
>= error_messages_for 'equipment'
%table.contentText{:style => "width: 100%"}
- if @types
%tr
%td Equipment Type
%td= collection_select 'equipment', 'equipment_type_id', @types, :id, :name, {}, :class => "dropdownSelect"
%tr
%td Location
%td= select 'equipment', 'equipment_location_id', @equipment_locations.collect { |e| ["#{e.name.capitalize!}", e.id]},{}, :class => "dropdownSelect"
%tr
%td Serial Number
%td= text_field 'equipment', 'serial_number', :class => 'textFields'
%tr
%td MAC Address
%td= text_field 'equipment', 'mac_address', :class => 'textFields'
%tr
%td IP Address
%td= text_field 'equipment', 'ip_address', :class => 'textFields'
- if @stands
%tr
%td Stand
%td= collection_select 'equipment', 'stand_id', @stands, :id, :street_no, :include_blank => true
%tr
%td{:valign => 'top'} Description
%td= text_area 'equipment', 'description', :cols => 45, :rows => '3', :class => "txt_area_effect"
我的新观点如下:
> %h3 New equipment
%div{:style => "border: 1px solid #CCC;"}
- form_tag :action => 'create', :estate_id => @estate do
= render :partial => 'form'
= submit_tag "Create"
- action = "list"
%input{:type => "button", :value => "Back", :onclick => "window.location='#{action}';", :class => "start"}
我的创建动作在我检查时显示为零
@equipment = Equipment.find(params[:equipment])
它会出现类似
的错误 Unknown key(s): equipment_type_id, mac_address, description, equipment_location_id, serial_number, ip_address
答案 0 :(得分:1)
@equipment = Equipment.find(params[:equipment])
应该是:
@equipment = Equipment.new(params[:equipment])
或
@equipment = Equipment.new(params[:equipment])
(只是发表评论的回答,所以这停止显示为未答复)