0

What is the equivalent of match 'aliased/route/here' => 'pointed/route/here'?

I'm banging my head on the wall here, because I can't get Devise to work with different login url's for the same model. If anyone has tips regarding this issue, I appreciate it!

The current version of my routes looks like this:

auth.devise_for :somerole,    :class_name => 'MainRole', :as => 'niceurl'
auth.devise_for :anotherrole, :class_name => 'MainRole', :as => 'otherurl'

But the :class_name option does not all the work: I'm still required to create all the appropiate helpers for every role I define.

I am currently using Devise 1.x in a Rails 2.3.8 environment, so that's why the solution offered on Github and mentioned on other questions won't work.

Thanks in advance!

Update

Okay, so I found a workaround for Devise to work: I created a method in my application_controller that collects all my different roles and assigns it to the mainrole like so:

def current_mainrole
  current_somerole || current_anotherrole
end

I'm afraid it might introduce some securityleaks and it really looks like a hack, so I'm hoping still someone can help me out with the routing issue.

Justus Romijn
  • 15,699
  • 5
  • 51
  • 63

1 Answers1

0

The equivalent in 2.3.8 is

map.contact '/contact', :controller => 'pages', :action => 'contact'

So you can tailor the line to your needs.

Take a look at these links for further reading:
Ruby on Rails Tutorial 2.3
Ruby on Rails Guides 2.3.8

Hope I helped.

Theo Scholiadis
  • 2,316
  • 2
  • 22
  • 33
  • I'm familiar with named routes, but with the use of Devise it is a bit more complicated than just pointing to a controller and action, unfortunately. Devise also takes the url you are using into account for naming helpers and stuff, so I really want to point one url to another. – Justus Romijn Apr 18 '12 at 15:07
  • My appologies. The little I played with devise was with Rails 3, and I decided to write my own. It was a bad assumption on my part... – Theo Scholiadis Apr 18 '12 at 22:41