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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=.