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 -- Posted via http://www.ruby-forum.com/.
Sorry for the pseudo-repost, maybe I didn''t do a good enough job explaining it the first time around or maybe I''m an island unto myself ;) So - simplified this time around: Given the following method: def do_login if Account.find_some_account(foo, bar) redirect_to :controller => ''xxx'' else #### I''d like to inform the user here that we''ve had an issue... #### I could just use flash, but I''m wondering what I should do #### if I want to report back multiple errors...is it considered #### bad-form to return an @errors array from the controller tier? redirect_to :controller => ''xxx'', :action => ''display_create'' end end Thanks for any help! Interesting to see how quickly this list moves! Cory Wilkerson -- Posted via http://www.ruby-forum.com/.
On 12/2/05, Cory Wilkerson <coryw@americanmonkey.com> wrote:> Sorry for the pseudo-repost, maybe I didn't do a good enough job > explaining it the first time around or maybe I'm an island unto myself > ;) > > So - simplified this time around: > > Given the following method: > > def do_login > if Account.find_some_account(foo, bar) > redirect_to :controller => 'xxx' > else > #### I'd like to inform the user here that we've had an issue... > #### I could just use flash, but I'm wondering what I should do > #### if I want to report back multiple errors...is it considered > #### bad-form to return an @errors array from the controller tier? > > redirect_to :controller => 'xxx', :action => 'display_create' > end > endI see no reason why you couln't put more than one error in the flash. Good luck, - Rowan -- Morality is usually taught by the immoral. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails