I am learning Ruby and Devise and for some reason users who are not logged in, are not getting redirected to be logged in.
Here is the route I have:
scope :module => :mobile, :as => :mobile do
constraints(:subdomain => /m/) do
devise_for :users, :path => "", :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "signup" }, :controllers => {:sessions => "sidebar/sessions"}
resources :home
resources :disclosures # Will have new, get, look up a disclosure
devise_for :users, :path => "", :path_names =>
{ :sign_in => "login", :sign_out => "logout", :sign_up => "signup" }
end
end
and here is my controller:
class Mobile::HomeController < ApplicationController
layout "mobile/application"
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
def index
respond_to do |format|
format.html
end
end
def create
end
end
Any idea why the user isn't being redirected to log in? Right now, the user is just being shown the page where he can only see if authenticated.
Thanks!
change this line:
before_filter :authenticate_user!, :only => [:edit, :update, :destroy]
to
before_filter :authenticate_user!, :only => [:index, :edit, :update, :destroy]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.