Check boxes for a has_many and belongs_to association.
Posted
by
Thomas
on Stack Overflow
See other posts from Stack Overflow
or by Thomas
Published on 2011-01-13T23:49:19Z
Indexed on
2011/01/13
23:53 UTC
Read the original article
Hit count: 183
ruby-on-rails
|ruby-on-rails-3
I have a has_many and belongs_to association.
class Link < ActiveRecord::Base
has_and_belongs_to_many :categories
belongs_to :property
end
class Property < ActiveRecord::Base
has_many :links
end
In the index and show I have <%= link.property.name %>
and it will show the Property that I assigned to the link with the console just fine.
I have a problem with figuring out how to show check boxes in the _form that assign a property to the link (a drop down would work as well).
It seems everyone who has had this question before has ether a has_many :through or a HABTM relationship and I can't seem to adapt their answers.
© Stack Overflow or respective owner