我有这两个模型:
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
在 registers/_form.html.erb 我想使用 f.collection_select 我可以从列表中选择一个人的名字。Register 模型的目的是记录结帐的历史。
这是我第一次尝试使用 collection_select,我无法用我在 stackoverflow 和 google 上阅读的示例来解决这个问题。也许我没有模型中需要的所有东西?
请帮忙。