views:

82

answers:

1

I am creating an equipment and I have two actions in my equipment controller, new and create.. and I have two views which is new and a partial form..

I also have four tables.. which are equipments, equipment_types, equipment_locations, and equipment_management_informations..

The form looks like..

>= 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"

and my new view is like:

> %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"}

and my create action display this a nil when i inspect it

   @equipment = Equipment.find(params[:equipment])

it gives an error like

 Unknown key(s): equipment_type_id, mac_address, description, equipment_location_id, serial_number, ip_address
+1  A: 
@equipment = Equipment.find(params[:equipment])

should be:

@equipment = Equipment.new(params[:equipment])

or

@equipment = Equipment.new(params[:equipment])

(just posting answer from comments so this stops showing as unanswered)

AdminMyServer