if @user.update_attributes(params[:user]) flash[:notice] = "User was successfully updated." redirect_to edit_admin_user_path(@user) else render :edit end end Nice :) The former solution look more clean for me - I see clearly that we disable some magic for some duration.The latter looks very confusing and looks wrong at the first look, before you reach the "AHA! If the size of the nested attributes array exceeds the specified limit, Nested Attributes:: Too Many Records exception is raised.If omitted, any number associations can be processed.The response to his dilemma was pretty outstanding.
One good example of this that I’ve been using recently is the accepts_nested_attributes_for helper in Rails.
You will probably want to rescue the exception after the transaction is rolled back: Active Record:: Base.transaction do user.update e end However, you don't really want to catch ALL exceptions. Now you should probably read the documentation: Record/Transactions/Class object failed validations and did not get saved to the database.
Problem 2: I thought some code was not saving records to the database, when, in fact, it was.
This works across tables, but not across multiple database connections.
If you have multiple database connections read the documentation to see how to handle it: Record/Transactions/Class