legendary_rob
legendary_rob

Reputation: 13012

Rails unique routing names

i am busy working on a project that is involving many sub-domains and man different levels of authentication, i would like to change what the URL looks like depending on your lvl of access, we have superuser which has access to all(programmers only), and then several different administrative rights. each have access to different things depending on what they deal with, a portal administrator has access to a feature called data_report, only he and the superuser can gain access, the way it was routed was intended for superuser access only so the URL shows http://toolkit.dev/portal_data/21 the 21 is the account the portal admin comes from, but he doesn't need to see that, since he cant access any other accounts, where as a superuser can and would, is there a way to just hide the 21 in that URL and still pass it to the same place. so the superuser could see the account numbers and if it was a portal_administrator then he wouldnt??

my routes look like this:

map.resources :portal_data, :only => [:show, :create]
map.show_account_portal_datum '/portal_data/:id/account/:account_id/', :controller => 'portal_data', :action => 'show_account'

the controller that it refers to has a method

def show_account
  @account = @portal.accounts.find(params[:account_id])
end

sorry if it is a simple question its my first time dealing with routes.

Upvotes: 0

Views: 118

Answers (1)

dhoelzgen
dhoelzgen

Reputation: 1150

I think in this case the portal admin also has no need for an index page. What about just checking this in the index action, and rendering (no redirect) the same view as the show action does if the currently logged in user is a portal admin?

Just a quick idea, don't know if it would fit your needs.

Upvotes: 1

Related Questions