Get ID of the object saved with association
Posted
by
Pravin
on Stack Overflow
See other posts from Stack Overflow
or by Pravin
Published on 2011-01-12T09:37:19Z
Indexed on
2011/01/12
9:54 UTC
Read the original article
Hit count: 212
ruby-on-rails
|associations
Hi, Here is my scenario:
I have three models Subscriber, Subscription, Plan
, with has_many :through
relationship
between Subscriber and Plans.
A subscriber can have multiple plans with one active plan. Whenever a subscriber selects a plan I save it using accepts_nested_attributes_for :subscriptions
. I get one plan from the form.
Now my problem is I want to get the ID of the record created in subscriptions table.
© Stack Overflow or respective owner