I have currently two Devise models Company and Contractor.
When they sign in I want to redirect them to a dashboard page. At the moment I have a before_action on the dashboard controller that only allows authenticate_company! so when a contractor signs in they can't view the dashboard.
Anyone done something like this before? Also is there an easy way to check which user is currently logged in so that I can show them different partial views?
Thanks in advance
I would just make a custom before_action:
before_action :authenticate_company_or_contractor! def authenticate_company_or_contractor! redirect_to root_path, alert: "You aren't allowed to do that" unless company_signed_in? || contractor_signed_in? end
And voila. You're done. This is basically the exact same thing that
authenticate_user! (or company or contractor, etc) implement behind the scenes. Nothin fancy!
Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.