i need help setting up the routes for my app. I have created about 10 controllers in the app/controllers/pro directory: app/controllers/pro/address_controller.rb app/controllers/pro/certification_controller.rb app/controllers/pro/program_controller.rb app/controllers/pro/program_controller.rb and so on... The problem is that I would like to also use app/controllers/pro as a controller; so app/controllers/pro_controller.rb i know my routes are wrong but this is what i have: map.connect ':controller/service.wsdl', :action => 'wsdl' map.connect "pro/:controller/:action" map.connect "pro/", :controller=>"pro", :action=>"index" # Install the default route as the lowest priority. map.connect ':controller/:action/:id' Any help would be appreciated, Nate
on 2006-06-08 23:33
on 2006-06-08 23:48
> The problem is that I would like to also use app/controllers/pro as a > controller; so app/controllers/pro_controller.rb If you want your app to work in the simple way that most people do, you shouldn't have to mess with custom routes too much. for instance, if you are developing on your localhost, 'localhost:3000/pro' should render the 'index' action of your pro controller automatically. Where you want to mess with your routes most of the time, is if you want to set up a default controller for something like localhost/, (the equivalent of www.site.com) There you can setup something like: map.connect '', :controller => 'pro', :action => 'index' which sets the base controller for your app for someone who arrives at yoursite.com instead of yoursite.com/pro. Does that clear anything up?
on 2006-06-09 00:13
Here is an explanation of routes: http://rails.outertrack.com/notes/list_new
on 2006-06-09 00:44
I think i understand how routes work and that explanation also helps but the problem i'm running into is this... without specifying any routes (except for the default) when i try to go to localhost:3000/pro it works and takes me to the index action of the app/controllers/pro_controller.rb; however, when i try to go to localhost:3000/pro/address I want to access the index action of app/controllers/pro/address_controller.rb but instead it's looking for the address action of app/controllers/pro_controller.rb . that's essentially where my problem is; do i need to configure routes to get around this? I know that i could create an individual route for every controller under app/controllers/pro like map.connect 'pro/address/:action', :controller=>"pro/address" but that just does not make sense to me.
on 2006-06-09 01:06
You have conflicting controllers. You can't have a pro controller and a pro folder... you've got to pick one or the other. Best thing do do is make a pro/base_controller.rb and then route requests for pro/ to that one. map.connect 'pro/:action/:id, :controller => "pro/base" See if that works. (untested but modified from a project where I do this with 'admin/'
on 2006-06-09 01:19
Brian H. wrote: > You have conflicting controllers. > > You can't have a pro controller and a pro folder... you've got to pick > one or the other. > > Best thing do do is make a pro/base_controller.rb and then route > requests for pro/ to that one. > > map.connect 'pro/:action/:id, :controller => "pro/base" > > See if that works. (untested but modified from a project where I do > this with 'admin/' Brian, I see where you're going with this but when i do that and then try to access pro/address or any other pro/controller it thinks that address is the action of base now.. as opposed to it's own controller
on 2006-06-11 05:51
Paste your routes file. It has to do with the order of the routes.
on 2006-06-11 06:24
What you are doing wrong is that your controller is not named pro but pro/pro. You did create the by the command script/generate controller 'pro/pro' right? This should work: map.connect 'pro', :controller => "pro/pro", :acton => 'index' An then remove the line map.connect "pro/:controller/:action" as the default route should be fine. On 6/8/06, Nate C. <firstname.lastname@example.org> wrote: > The problem is that I would like to also use app/controllers/pro as a > > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > email@example.com > http://lists.rubyonrails.org/mailman/listinfo/rails > --
on 2006-06-11 06:28
Whoops.. Didn't read your mail well enought. Sorry. Silly me. you can't have both pro and also pro/something controllers. It has to be named as something else. I'm guessing you are trying to make a page that is /pro and then if you click something there you go to pages like /pro/address/12 Create a controller pro/front with action :index. map.connect 'pro', :controller => "pro/front", :acton => 'index' On 6/11/06, Jon Gretar B. <firstname.lastname@example.org> wrote: > > > > > :action=>"index" > > -- > Jon Gretar B. > http://www.jongretar.net/ > --