_path and _url helpers not working with scaffolding

Here is what is happening, I have rails 2.0.2 on both my local PC
running windows XP and my server which is linux.

So I generated scaffolding on windows by doing

script/generate scaffolding MyRec fld:string fld2:string

and so on,

then when I moved the code over to linux I kept getting errors for
methods of the form:
mycontroller_path and mycontroller_url being undefined for the
controllers generated for the scaffolds. I looked around on google a
bit, and didn't have any luck.
Something about adding something to routes.rb didn't seem to work with
a quick try.

I started to define method_missing in my applications_controler and
applications_helper, but
I'm not sure if there is an easier way to fix this ? I had some
success initially doing this, but it seems complex a bit.

method_missing is the wrong approach for sure
You must define the resources in routes.rb

if the controller is name my_controller, it should look like:

map resources :my

if that doesn't help, please post more info.
controller name, the generated code that gives the error

I did start to go down the named routes path. What mystifies me is
that I tried generating scaffolding on linux.
If the scaffolding is generated on linux it seems to work fine, but
if it's generated on windows and copied to linux,
it doesn't work quite right, even though it all appears to look the
same. What I don't get at all is the scaffolding creates
named routes, but I don't see where they are created. That's basically
where the problem is. So I went and
added some routes by hand in routes.rb for one of my controllers like

  map.criteria 'criterias',
  :controller => "criterias",
  :action => "index"

  map.criteria 'criteria/edit/:id',
  :controller => "criterias",
  :action => "edit"

  map.criteria 'criteria/show/:id',
  :controller => "criterias",
  :action => "show"

Now I changed my scafolding to look like this for show and edit:

    <td><%= link_to 'Show', show_criteria_path(criteria) %></td>
    <td><%= link_to 'Edit', edit_criteria_path(criteria) %></td>

Show works fine, but when I click on an edit, it appears that my
controllers edit method gets called and
then it calls render the template. That works fine, I have log
messages in the template. The very last line of the template is a log
message that shows up in the log ("inside template 4") bellow. The log
indicates a 200 status, but the browser gets a 500 status

  Parameters: {"action"=>"edit", "id"=>"7", "controller"=>"criterias"}
#<Criteria id: 7, title: "test", description: "", salary: "",
work_type: "", location: "", zip_code: "", created_at: "2008-07-16
08:26:57", updated_at: "2008-07-16 08:26:57">
Rendering template within layouts/main
Rendering criterias/edit
inside template#<Criteria id: 7, title: "test", description: "",
salary: "", work_type: "", location: "", zip_code: "", created_at:
"2008-07-16 08:26:57", updated_at: "2008-07-16 08:26:57">
inside template 1
inside template 2
inside template 3
inside template 4
Completed in 0.06958 (14 reqs/sec) | Rendering: 0.01398 (20%) | DB:
0.00000 (0%) | 200 OK [http://itjobs.freespiritboston.net/criteria/

after a bunch of reading and messing around, it seems like if I do my
routing like this for
each of my scaffolded controllers, then it all seems to work:

  ['criterias', 'applicants', 'companies'].each do |ctl|

    map.send(ctl, ctl,
             :controller => ctl,
             :action => 'create',
             :conditions => {:method => 'post'})

    map.send(ctl.singularize, ctl.singularize + '/' + ':id',
             :controller => ctl,
             :action => 'destroy', :id => /\d+/,
             :conditions => {:method => 'post'})

  map.recname 'recname/:id'
  :controller => "recnames",
  :action => "show",
  :id => /\d+/

    map.send(ctl.singularize, ctl.singularize + '/' + ':id',
             :controller => ctl,
             :action => 'show', :id => /\d+/)
  map.action_recname 'recname/edit/:id',
  :controller => "recnames",
  :action => action,
  :id => /\d+/

    map.send('edit_' + ctl.singularize, ctl.singularize + '/edit/' +
             :controller => ctl,
             :action => 'edit', :id => /\d+/)

    map.resources ctl


shouldn't that be

script/generate scaffold my_rec fld:string fld2:string

Hi, if you want test if your restful routes are working correctly, you can do the following in the root directory of your rails application:

  1. add the following to your routes.rb located in the config directory:

map.resources :records

  1. execute the following:


  1. Now, type


Next, the plural of criteria is criterion. Now, how can I correct the inflector to produce the correct pluralization of criteria? You can add the following at the bottom your application’s environment.rb file:

Inflector.inflections do |inflect|

inflect.irregular ‘criteria’, ‘criterion’


  1. Now, when you’re in script/console, you should get the correct pluralization of criteria:


=> “criterion”

Good luck,


hate to be pedantic, but in fact 'criterion' is the singular and
'criteria' is the plural.


i'd bet rails would correctly pluralise criterion to criteria, but not
the other way round, because thats wrong.

- mungler

in fact, criterion is the singular and criteria is the plural:

i'd bet rails would *correctly* pluralize criterion to criteria, but
not the other way round...

- mungler