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: 216

Filed under:
|

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

Related posts about ruby-on-rails

Related posts about associations