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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -