On May 4, 10:54 am, MaggotChild <[email protected]> wrote: > On May 3, 5:15 pm, Jeremy Evans <[email protected]> wrote: > > > On May 3, 4:48 pm, MaggotChild <[email protected]> wrote: > > > Is there a setting and/or alternate method that would throw an > > > exception if a record was not found? > > > No one has asked for it. I don't have a personal need for it, but if > > there is strong community demand, I'd consider a patch. It's fairly > > easy to add a method to Sequel::Model yourself that raises instead of > > returning nil if a record is not found, FWIW. > > Useually several actions retrieve a single record and maybe some child > records. When this record is not found I think it's easier to handle > it once, for all actions, with a 404 via rescue_from. I believe a > similar functionality can be achieved with a before_filter or, as > you've said, I can modify Sequel::Model. Anything to avoid the > repetitiveness of checking for nil in an action or view. > > What do you useually do?
Usually I'm using Sinatra, and if I want to stop processing if a record isn't found: halt(...) unless @record = Record[params[:id].to_i] I guess that's what you want to avoid, though. Often my ... varies action to action, so a generalized rescue approach would provide a less specific error message. Any Sequel users want to chime in with their thoughts on this? Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
