I18n-Flash-Messages-with-Devise-and-Bootstrap
routes.rb
root :to => 'users#index'
devise_for :users, :controllers => {:registrations => "registrations", :sessions => "sessions"}
devise_for :users do
get '/users/sign_in', :to => 'devise/sessions#new', :as => :new_user_session
get '/users/sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session
get "/users/sign_up", :to => "registrations#new"
end
When I try to access localhost:3000, I will directed to localhost:3000/users/sign_in and that's normal, because of filter, but however I will get a validation message
You need to sign in or sign up before continuing
How to avoid this?
I tried changing by using match in routes that didn't help out.
Edit: Consider a scenario: (without user session) if I try to access /roles will be redirected to sign in path, at that point I would require msg. or I would loose other flash validations such as sign-out, email-exists, pwd wrong.
Tell Application to use root as sessions#new if user not logged-in
config/routes.rb
authenticated :user do
root :to => "users#index"
end
unauthenticated :user do
devise_scope :user do
get "/" => "devise/sessions#new"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With