Another Problem with params

I am trying to do a similar thing for some spares that I am trying to

My spare.rb file is as under

class Spare < ActiveRecord::Base
belongs_to :department, :class_name => ‘department’, :foreign_key
=> ‘department_id’
belongs_to :subequipment, class_name => ‘subequipment’,
:foreign_key => ‘sub_equipment’

My view reads

<% @departments.each do |department_id| %> <%= department_id.department_name %> <% end %>

Sub equipment
<% @subequipments.each do |subequipment| %> <%= subequipment.sub_equipment_name %> <% end %>

It works fine if I have only one foreign key say department. When I
try to introduce a second one like sub-equipment by adding the line
belongs_to :subequipment, class_name => ‘subequipment’, :foreign_key
=> ‘sub_equipment’

I get the following error
ArgumentError in Admin#create Unknown key(s): Spare

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace |
Full Trace
assert_valid_keys' C:/InstantRails_1_0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:inbelongs_to_without_reflection’
(eval):5:in belongs_to' #{RAILS_ROOT}/app/models/spare.rb:6 #{RAILS_ROOT}/app/controllers/admin_controller.rb:24:increate’


Parameters: {“commit”=>“Create”, “spare”=>{“nature”=>“C”,
“remarks”=>"", “pattern_number”=>“mbm-50”, “description”=>“akjl”,
“subequipment”=>“1”, “equipment”=>“1”, “department_id”=>“1”,
“section”=>“1”}, “location”=>{“box_number”=>"", “compartment”=>"",

Show session dump

flash: !map:ActionController::Flash::FlashHash {}

Response Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}

On 3/22/06, Liquid [email protected] wrote:

<%= text_field “student”, “department_id” %>


the method
new student to the database


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs