Cool. You probably want to give it a meaningful exception and message though ;)

On 8/22/06, Doug Johnston <[EMAIL PROTECTED]> wrote:
Nice call Kevin...I think I might give that a try!

Doug


On 8/22/06, Kevin Clark <[EMAIL PROTECTED] > wrote:
> This'd be easy to hack out though..
>
> def update_attributes!(*args)
>   unless update_attributes(*args) raise "AHHHHHHHHHHH"
> end
>
> On 8/22/06, Chris Abad <[EMAIL PROTECTED]> wrote:
> >
> > I don't think update_attributes or push have bang versions. If they do,
they
> > don't appear in the API.
> >
> >
> >
> > On Aug 22, 2006, at 11:51 AM, Doug Johnston wrote:
> > Great discussion guys!  Can this be used on other methods that save to
the
> > database?  For instance:
> >
> > @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
> >
> > _______________________________________________
> > Sdruby mailing list
> > [email protected]
> > http://lists.sdruby.com/mailman/listinfo/sdruby
> >
> >
> >
>
>
> --
> Kevin Clark
> http://glu.ttono.us
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
>


_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby





--
Kevin Clark
http://glu.ttono.us
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to