i don't know if i understand what you need, but i usually put various checks on a befor_filter. if conditions are not met you will simply return false and the execution stops.
On 19 Nov, 23:39, candlerb <b.cand...@pobox.com> wrote: > Is there a standard way in Rails of terminating a request early with > throw or raise? > > I am thinking of when a controller invokes a private method and inside > that method I wish to render a result and then finish. For example: > > def my_action > ... > authorize_something > ... > end > > private > def authorize_something > ... > if some_failure_condition > flash[:error] = "I couldn't do that" > redirect_to :controller=>:top, :action=>:index > throw :request_complete # <<< WHAT GOES HERE? > end > end > > that is, without having to put an explicit catch or rescue in every > action which calls authorize_something, and without having to check > the return value from authorize_something everywhere that it is > called. > > I have found 'rescue_from'; however this doesn't do what I need > because my Cucumber tests still abort with the exception. That is, it > seems that rescue_from is intended to handle pretty display of error > pages when "real" exceptions occur, not as a mechanism by which a user > exception can signal the early (but successful) termination of a > request. > > Is there any other facility I should be looking at? > > Many thanks, > > Brian. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.