0

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.

legendary_rob
  • 12,792
  • 11
  • 56
  • 102

1 Answers1

1

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.

dhoelzgen
  • 1,150
  • 7
  • 15
  • thats what i was thinking aswell, but its not very dry since its exactly the same code, and its already a monolithic program. what i am looking for is something like match? for example: match 'show_account' => 'portal_data' ... just need some way of separating it from super user... mmm thanks i am brain storming alot lol – legendary_rob Apr 12 '12 at 12:11
  • Hmm, jep, that would not be completely dry, but you could use one method for the logic and the two actions only as gateways I think... I don't know any way for matching routes like in your example, sorry. – dhoelzgen Apr 12 '12 at 13:12
  • it cool, the only reason i was trying is because i overheard one of our senior developers talking about solving a problem simular to this by doing it that way.. ill go ask him for some help. thanks for the suggestions though :D – legendary_rob Apr 12 '12 at 13:35