Dynamic Routing in Rails for landing page -


i have in routes.rb

get 'admin', to: 'admin/appointments#index' 

i want route dynamic based on user logs in. can't this, should set this?

get 'admin', to: @current_admin.landing_page 

it sounds you're trying introduce controller logic routes. want 1 admin_landing_page route, supply current user parameter.

so in routes, want this

get 'admin', to: landing_page/:admin_identifier 

and in controller

@current_admin = youradminmodel.find(params:[:admin_identifer]) 

then can use @current_admin in view customize based on data current_admin, such as

<h1>welcome homepage of admin <%= @current_admin.name %>!</h1> 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -