Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Multiple Devise Users sharing a dashboard

Rails • Asked by Stephen Sizer


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

Hey Stephen,

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?

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!

Thanks for the super speedy response :)

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.