ruby on rails - Different views for different Devise users -


i have 3 devise models in application: users, publishers, , content creators.

publishers inherit content creators, , content creators inherit users.

i put custom index.html.erb file in each of these model's view folders want display instead of default user index.html.erb file, meaning, if publisher logs in, want them see index.hml.erb in views/publishers instead of 1 in posts.

i have created separate controllers content creators , publishers have index action. routes file:

  devise_for :users   devise_for :publishers , :controllers => { registrations: 'registrations' }   devise_for :content_creators    resources :posts    'tagged' => 'posts#tagged', :as => 'tagged'   root "posts#index" 

how can configure routes file this?

as user, in view can check by

if current_user.publisher?   <%= render 'view_for_publisher' %> elsif current_user.content_creator?   <%= render 'view_for_content_creator' %> else   <%= render 'default_view' %> end 

or in controller, instead of render, can redirect action desired view. hope it'll help.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -