Rails landing page routing and devise -


my website should works facebook.com. if user logged , if goes "/" should rendered home controller. if isn't logged should render landing_page controller

"/" && user_signed_in? ---> home controller

"/" && user_not_logged ---> landing_page controller

i'm using rails 4 , devise

applicationcontroller

class applicationcontroller < actioncontroller::base    before_filter :authenticate_user! end 

routes.rb

get "landing_page/index"  root 'home#index', :as => :home 

how keep "before_filter" in applicationcontrol run in every controllers except "landing_page" controller?

update

if go "/en/landing_page" render landing_page controller correctly (logged out), if go "/" redirect me "/users/sign_in"

class landingpagecontroller < applicationcontroller   skip_before_action :authenticate_user!    def index   end  end  class applicationcontroller < actioncontroller::base    before_action :authenticate_user!  end 

routes.rb

 root 'landing_page#index' 

solved!

landingpagecontroller

class landingpagecontroller < applicationcontroller   skip_before_action :authenticate_user!    def index   end  end 

homecontroller

class homecontroller < applicationcontroller   skip_before_action :authenticate_user!   before_action :check_auth  def check_auth     unless user_signed_in?         redirect_to :controller => :landing_page     end end  end  

applicationcontroller

class applicationcontroller < actioncontroller::base    before_action :authenticate_user!  end 

routes.rb

 root 'landing_page#index' 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -