I just installed this and for the most part it works great, and all in about 1/2 an hour! Nice. But I have just one small problem. I would have expected an error message if login fails, but it just stays on the login page. I tried adding an "else" to the login method of the AccountController, but the flash message doesn''t show up. I''m missing something obvious here probably.. def login return unless request.post? self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? if params[:remember_me] == "1" self.current_user.remember_me cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } end redirect_back_or_default(:controller => ''/account'', :action => ''index'') flash[:notice] = "Logged in successfully" else #my added code flash[:warning] = ''Login failed'' #my added code end #my added code end --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dailer wrote:> flash[:notice] = "Logged in successfully" > else > flash[:warning] = ''Login failed'' #my added code >I think most default/scaffold views in Rails only show notices e.g. flash[:notice] You probably need to improve your flash message code to include :warning, this was discussed recently on this list. http://groups.google.com/group/rubyonrails-talk/search?hl=en&group=rubyonrails-talk&q=simple+exists%3F+question&qt_g=Search+this+group cheers, Anthony Richardson --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Try it: if logged_in? if params[:remember_me] == "1" self.current_user.remember_me cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } end redirect_back_or_default(:controller => ''/home'', :action => ''teste'') flash[:notice] = "Login successfully" else flash[:notice] = "Login ou senha failed" end If you really need flash[:warning] because some specific formatation in your layout, you have change layout and add <%= flash[:warning] %> On Wednesday 12 September 2007 17:52:29 dailer wrote:> I just installed this and for the most part it works great, and all in > about 1/2 an hour! Nice. But I have just one small problem. I would > have expected an error message if login fails, but it just stays on > the login page. I tried adding an "else" to the login method of the > AccountController, but the flash message doesn''t show up. I''m missing > something obvious here probably.. > > > def login > return unless request.post? > self.current_user = User.authenticate(params[:login], > params[:password]) > if logged_in? > if params[:remember_me] == "1" > self.current_user.remember_me > cookies[:auth_token] = { :value => > self.current_user.remember_token , :expires => > self.current_user.remember_token_expires_at } > end > redirect_back_or_default(:controller => ''/account'', :action => > ''index'') > flash[:notice] = "Logged in successfully" > else #my added code > flash[:warning] = ''Login failed'' #my added code > end #my added code > end > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---