I have a devise model called admin which gives me current_admin and the model has a method called role, which is either 'free' or 'standard' or 'premium'.
I have a dashboard_controller with three actions:
def index ... end def free ... end def premium ... end
I have a passthrough_controller that handles which dashboard action an admin should be redirected to based on their role:
class PassthroughController < ApplicationController def index path = case current_admin.role when 'free' dashboard_free_path when 'standard' dashboard_standard_path when 'premium' dashboard_premium_path else admin_signin_path end
redirect_to path end end
And I have these routes set up:
devise_for :admins do match "/admins/sign_out" => "devise/sessions#destroy" match "/dashboard/index" => 'passthrough#index' match "/dashboard/free" => 'dashboard#free', :as => :dashboard_free_path match "/dashboard/standard" => 'dashboard#standard', :as => :dashboard_standard_path match "/dashboard/premium" => 'dashboard#premium', :as => :dashboard_premium_path end
This isn't working, but I'd like to know why it isn't working and where I'm going wrong.
Thanks