Hello,
I have two tables "people" and "relations"
Following are the models
class Person < ActiveRecord::Base
has_and_belongs_to_many :relations
class Relation < ActiveRecord::Base
has_and_belongs_to_many :people
I want to select multiple relations and when i say
Person.create(params[:person]) in controller
the relation ids and and id of person should be stored in
people_relation table.
Here is the form for person.
<%form_for (:person,:url=>{:action =>"create"},:html => {
:multipart =>
true })do |p|%>
<%= p.collection_select :relation_ids, Relation.find(:all, :order =>
''relation_name ASC''), :id, :relation_name, { :selected =>
p.relation_ids
}, { :multiple => true, :name => ''p[relation_ids][]'' }
-%></td>
<%end%>
I am getting error undefined method name relation_ids
how should i write the above piece of code so that the selected
relation_id and person_id go into the people_relations table.
Thank you.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---