I have these 2 models:
class Person < ActiveRecord::Base
attr_accessible :contact, :name
validates :name, :presence => true
has_many :books
end
class Register < ActiveRecord::Base
attr_accessible :checkin, :checkout, :notes, :person, :book
end
In registers/_form.html.erb I want to use f.collection_select where I can select a Person’s name from a list. The purpose of the Register model is to record a history of checkouts.
This is my first time trying to use collection_select and I can’t wrap my head around it with the examples I have read on stackoverflow and google. Maybe I don’t have all that is needed in the models?
Please help.
There are errors in your model with regards to associations. The correct associations should be:
Then in your
registers/_form.html.erbyou have to have something like the following: