开发者

Configuring routes in rails application

开发者 https://www.devze.com 2023-02-21 13:19 出处:网络
HI, I have created a custom index page f开发者_如何转开发or my application , which has two image links , one for users and other for admin. How shall I configure the routes in the routes.rb, so that

HI,

I have created a custom index page f开发者_如何转开发or my application , which has two image links , one for users and other for admin. How shall I configure the routes in the routes.rb, so that the links take to the dedicated pages.

Thanks.


May be create condition in the template:

<% if @currentUser.isAdmin %>
....
# image link one
....

<% else %>
....
# image link two
....
<% end %>


if you have two controllers, say Admins and Users, you could say in your routes

resources :admins
resources :users

and in your index view write something like

<%= link_to 'admins', admins_path %>
<%= link_to 'users', users_path %>

for more about routing and rails in general please read the rails guides available here

0

精彩评论

暂无评论...
验证码 换一张
取 消