Topic: Help! My route is haywired

Hi all, I have some routing question. On my local machine and another's friend local development (both are Mac+Mongrel+MySQL+Rails 1.2.3 + Ruby 1.8.6), the application is all running fine except on my staging server which is on (Mongrel+Ubuntu+PSQL+Rails 1.2.3+Ruby 1.8.5)

The problem is this:
1. I have 2 controllers (in folder and naturally namespaced using module) called /candidates/resumes and /candidates/resumes/general like this:

class Candidates::ResumesController < ApplicationController
  # code with index action

class Candidates::Resumes::GeneralController < ApplicationController
   code with index action

When I GET this URL, /candidates/resumes/general

Rails on my staging is dis-oriented and tell me there is no "general" action on the ResumeController when in fact i am asking for the "index" action of the GeneralController.

The problem is my Mac development and my friend's work fine.. Any one has encounter this problem? Thanks a lot smile

Re: Help! My route is haywired

You're defining a general controller rather than a general action.

Have a look into nested RESTful routes, particulary the post by Jamis Buck.

Also the cheat sheet is very helpful.

What you should be doing is defining a candidates controller, i.e. class CandidatesController and then a completely seperate Resumes controller, i.e. class ResumesController and do all the linking in the models i.e. candidate.rb: has_many :resumes. In your resumes controller define something like a show action which then you can pass in the id of General so you get a nice little link like /resumes/show/General to show all the general ones.

Re: Help! My route is haywired

Hmms.. I am not using RESTful actually and not intended to use now (maybe later)..
You are rite, I am defining a GeneralController and I want that GeneralController and it has nothing to do with ResumeController. The problem is Rails should recognize it since it 'did' recognize it on my Mac development machine..

I have 2 controller and it is intended...

/candidates/resumes                     -----> This has namespace like this Candidates::ResumesController

/candidates/resumes/general        -----> This has namesoace like this Candidates::Resumes::GeneralController

But when i go to the URL http://host/candidates/resumes/general and expecting the GeneralController to get called and the "index" action to be invoked.. somehow Rails mistaken it and said there is no "general" action on my ResumeController.

Thanks for replying.. smile