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

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -