Routes problem

I want to connect default route to controller Report::SalesController,
so I have line:
map.connect ‘’, :controller => ‘report/sales’
in config/routes.rb

SalesController is in app/controllers/report/sales.rb
and is declared as:
class Report::SalesController < ApplicationController

end

The problem is that when I try to open root url of my application I
get error message:
uninitialized constant SalesController

What I’m doing wrong?

if you have this route:

map.connect ‘’, :controller => ‘report/sales’

your controller would have to be named like this (as far as i know):

class SalesController < ApplicationController

On 13 November 2006 14:26, Domas S. wrote:

What I’m doing wrong?
The problem is that file with your controller should be named
sales_controller.rb (like class name, but underscored). Rails classes
are
loaded on demand and without proper naming Rails will not find which
file to
load.

So how can I write a route that redirects to Report::SalesController?

Try this:

map.connect ‘’, :controller => '/report/sales

Sorry, I mistyped controller file name, it is actually:
app/controllers/report/sales_controller.rb

So it seems that rails can’t guess controller class if it’s inside of
module.
I created this controller using:
ruby script/generate controller report/sales

So it seems to be supported. And I can activate the controller by going
to:
http://127,0,0,1:3000/report/sales

So the problem is only with routing.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs