Forum: Ruby on Rails Controller-tier errors

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cory W. (Guest)
on 2005-12-01 17:29
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 =>
        redirect_to :controller => 'profile', :action => 'display_edit'

Two questions:

1. 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?

2. 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.
This topic is locked and can not be replied to.