Hi,
I’d like to create the following setup with RoR:
www.mywebsite.com/subdir1/order/create
www.mywebsite.com/subdir2/order/create
I’d like both urls to call the same action in the same controller. How
can
I do this? I know this may be complicated, but I’m prepared to go a
long
way.
Shimon
In your controller:
class SubDir::OrderController < ApplicationController
end
In app/views you have to create subdir directory to put the views
concerning this controller.
That approach won’t quite give you what your after. That approach
will put a controller in a subdirectory, sure, but from what you said
you want the same action and controller accessed from two different
sub-directories.
To do this I would use routes. I don’t have a box with ruby on it in
front of me but from memory something like.
map.connect “/subdir1/:controller/:action/:id”
map.connect “/subdir2/:controller/:action/:id”
Should get you started. You can get very tricky with routes. Try
searching this list, along with the standard google, and doc search.
Cheers
Sorry, I didn’t get that
Daniel N is right, routes is what you’re looking for.
Correct me if I’m wrong, but won’t this solution simply allow the order
controller to be called from one subdir? Lets say I do as you
recommended:
class subdir1::OrderController < ApplicationController
def create
end
end
This will give me the following url:
www.mywebsite.com/subdir1/order/create
But I wan’t two urls to call the same controller/action:
www.mywebsite.com/subdir1/order/create
www.mywebsite.com/subdir2/order/create
How can I achieve this?
Shimon
Thanks, I will check that out!