Forum: Ruby on Rails Controller-tier errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee7be48e775d357de69db2754a377160?d=identicon&s=25 Cory Wilkerson (corywilkerson)
on 2005-12-01 16: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 =>
'display_create'
    else
        redirect_to :controller => 'profile', :action => 'display_edit'
    end
end

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