ruby on rails - How to update existing nested attribute w/ no FK -
assuming user has_one :subscription, subscription belongs_to :user, , using accepts_nested_attributes_for nest subscription attributes user creation form, best way locate , update , existing subscription (if exists) based on user.email == subscription.email?
note existing subscriptions have user_id = nil
probably want use email foreign key:
class user < activerecord::base has_one :subscription, :foreign_key => "email", :primary_key => "email" end
Comments
Post a Comment