RoR Folk,
So, here’s some logic I’ve got buried away in a Controller:
def do_login
if !(session[:profile] = Profile.find_by_foo_and_bar(x, y)
flash[:message] = ‘Unable to login…’
redirect_to :controller => ‘profile’, :action =>
‘display_create’
else
redirect_to :controller => ‘profile’, :action => ‘display_edit’
end
end
Two questions:
- I’m using the flash here - which works good and well, but I’m
wondering what the canonical way of moving errors up from the controller
layer is (when they’re not nicely rolled up into a model for you).
In the aforementioned case, let’s say I need to report three errors to
the view…I was considering just building an errors array, much like
what you find in ActiveRecord instances, and just bubbling that up via
@errors. Can someone give me some bearings?
- If anyone would like to layout any idioms re: the above method
implementaiton - I’d certainly welcome them. I don’t know enough about
Ruby yet to know when I’m being unnecessarily verbose.
Thanks for any help you can offer.
Cory