search for: build_profile

Displaying 3 results from an estimated 3 matches for "build_profile".

2012 Jul 28
1
`build_association` produces DB-queries
Let `User.has_one :profile`. I''ve always thought that `@user.build_profile` is a cheap thing to do - it''s just creating a new object without persisting it. But, in fact, it does 2 queries to the DB: `BEGIN` and `COMMIT`. In my app I have an admin users#index page where users'' details can be edited, and to simplify the code I build a profile whenever...
2008 Sep 11
0
session/marshalling
...dels. Partially the validation of the models is dependent on the other models. So i need to have them linked to each other from the beginning of the registration process. Also I need them to be saved to session. Now the problem is, if I do this: @membership = Membership.new @profile = @membership.build_profile @customer = @membership.build_customer @customer.profile = @profile # <= that’s the problem And then try to save @customer in the session: session[:customer] = @customer There is a 500 internal server error: NoMethodError (undefined method `marshal_dump'' for #<Class:0x2162504>...
2009 Nov 13
1
Delegates and building associations
Class User << ActiveRecord::Base has_one :profile delgate :description, :description=, :to => :profile end I''d like to do, @user = User.create(:name => ''Foo Bar'', :description => ''Slow.'') or @user = User.update_attributes(:description => ''Slow'') and have AR create/update the profile model and association (if