In case anyone is wondering here is the migration:
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.integer :company_id
t.references :contactable, :polymorphic => true
t.timestamps
end
end
def self.down
drop_table :people
end
end
On Apr 18, 7:50 pm, Me <[email protected]> wrote:
> It appears that I have the models and migrations set up correctly.
>
> In case anyone is wondering why i set it up like this I had it working
> with just a contact model and this will save a bunch of coding changes
> to my already working CRUD ajax inline contact form. I am adding a
> contrator model so I would like to have a polymorphic setup so I can
> differentiate the two types of people in the form.
>
> I have a Person that is polymorphic,, it will have a contact and
> contractor type.
>
> class Person < ActiveRecord::Base
> belongs_to :contactable, :polymorphic => true
> end
>
> class Contact < ActiveRecord::Base
> has_many :people, :as => :contactable
> end
>
> When I do:
>
> person = Person.create(params[:person])
> @contact = Contact.create(params[:contact])
> person.contactable = @contact
>
> It goes without an error but puts NIL in the contactable_type and
> contactable_id columns.
>
> Anyone have an idea why? I spent a couple hours with this earlier.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---