@page.update_attributes(params[:page])
or
@page.contents.push(@new_content)
Could I just add a ! on the end and have it raise an exception when it fails?
Doug
On 8/22/06, Chris Van Pelt <[EMAIL PROTECTED]> wrote:
We use .save! all the time. Just remeber it's probably gonna be best
to only catch the ActiveRecord::RecordInvalid errors otherwise when
you screw something else up it's a real pain to debug.
Transactions are more elegant for the multi save stuff, but save! is a
great way to deal with validation.
Chris
On 8/21/06, Chris Abad <[EMAIL PROTECTED]> wrote:
>
> That's true, that'd take a couple lines out of my code. Another thing I'm
> looking at is using .save! (inspired by some code I saw by TecnoWeenie) in
> combination with rescue ActiveRecord::RecordInvalid. Haven't tried yet to
> see how that plays with the transaction.
>
> .save returns true or flase, while .save! rasies an exception if it fails.
> Anyone tried using @object.save! with rescue rather than the traditional if
> @object.save?
>
>
> On Aug 21, 2006, at 1:31 PM, Stephen Waits wrote:
>
>
> As long as things are dependent on account.save and user.save, why not just
> put it all under the one transaction?
>
> @account = Account.new(params[:account])
> @user = User.new (params[:user])
> Account.transaction do
> if @account.save and @user.save
> @account.users << @user
> # Do something cool
> end
> end
>
> --Steve
>
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
>
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
>
>
>
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby
_______________________________________________ Sdruby mailing list [email protected] http://lists.sdruby.com/mailman/listinfo/sdruby
