Hi
I have two tables
1. devices
2. device_categories
both associated with each other via foreign key device_category_id in
device table. I use scaffold and create a base system. I associate the
two models together via belongs_to declaration in device model, and
has_many declaration in device_categories model. I also add a device
category drop-down box on create page to select required category for
device. Now when I try to create a new device records from front-end I
get the following error message:
ActiveRecord::AssociationTypeMismatch in Device#create
DeviceCategory expected, got String
/app/controllers/device_controller.rb:21:in `create'
script/server:51
Request
Parameters: {"device"=>{"name"=>"asdfsa",
“description”=>“dfasdfasdf”, “device_category”=>“3”, “model”=>“asdf”},
“commit”=>“Create”}
The given below is the code of device_controller.rb near line 21.
20 def create
21 @device = Device.new(params[:device])
22 23 if @device.save
24 flash[:notice] = ‘Device was successfully created.’
25 redirect_to :action => ‘list’
26 else
27 render :action => ‘new’
28 end
29 end
Thanks in advance of any suggestions to this problem.
Regards
Chetan
–
Srijan Technologies Pvt. Ltd.
304 Bakshi House,
40-41 Nehru Place,
New Delhi - 110019
INDIA
Ph: 91-11-2622 5926/ 5931
Fax: 91-11-5160 8543
Email: [email protected]
Web: www.srijan.in
See our Typo3 demos at: http://demos.srijansoft.com