HABTM problem

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.