# Routing problem

**URL:** <https://www.ruby-forum.com/t/routing-problem/152123>\
**Category:** Engines\
**Created:** [October 30, 2008, 10:33am UTC](https://www.ruby-forum.com/t/routing-problem/152123 "2008-10-30T10:33:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [October 30, 2008, 10:33am UTC](https://www.ruby-forum.com/t/routing-problem/152123/1 "2008-10-30T10:33:54Z")

</div>

Hi,

I’m developing an engine with a controller, and I have problems to  
configure the routing.  
The engine is located in vendor/plugins/web\_file\_attachment. Under  
that directory:

- the controller is in app/controllers/web\_file\_attachments.rb

- I’m trying with this controller classes:  
class WebFileAttachment::WebFileAttachmentsController \<  
ApplicationController  
and I have tried with equivalent configurations for class  
WebFileAttachmentsController \< ApplicationController

- in routes.rb, I have this (following the docs stating that the  
plugin name is the first part of the controller name):  
connect “/app/web\_file\_attachments/:action/:id”, :controller =\>  
“web\_file\_attachment/web\_file\_attachments”

And in the main rails config/routes.rb I have this:  
map.from\_plugin :web\_file\_attachment

I still end with this error:  
uninitialized constant  
WebFileAttachment::WebFileAttachmentsController

though this is exactly how I name my controller.  
If I try  
require ‘web\_file\_attachments’  
in init.rb, I get an error with ApplicationController not defined.

What am I doing wrong here?  
I’m using rails 2.1.1 and engines 2.0.0

Thanks in advance.

Raphaël

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [October 30, 2008, 10:50am UTC](https://www.ruby-forum.com/t/routing-problem/152123/2 "2008-10-30T10:50:55Z")

</div>

On 30 Oct 2008, at 09:33, Raphael B. wrote:

> and I have tried with equivalent configurations for class  
> I still end with this error:  
> uninitialized constant  
> WebFileAttachment::WebFileAttachmentsController
> 
> though this is exactly how I name my controller.  
> If I try  
> require ‘web\_file\_attachments’  
> in init.rb, I get an error with ApplicationController not defined.
> 
> What am I doing wrong here?  
> I’m using rails 2.1.1 and engines 2.0.0

The most obvious things are:

- if your controller is  
WebFileAttachment::WebFileAttachmentsController, then it should be in  
a file called vendor/plugins/web\_file\_attachment/app/controllers/  
web\_file\_attachment/web\_file\_attachments\_controller.rb
- if your controller is WebFileAttachmentsController, then it should  
be in a file called vendor/plugins/web\_file\_attachment/app/controllers/  
web\_file\_attachments\_controller.rb

Essentially - the name of the plugin isn’t involved in namespacing the  
controller, and the file needs to end with \_controller.rb. Hopefully  
that should get you back on track.

Thanks,

James

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [October 30, 2008, 12:15pm UTC](https://www.ruby-forum.com/t/routing-problem/152123/3 "2008-10-30T12:15:57Z")

</div>

On Thu, Oct 30, 2008 at 10:50 AM, James A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > class WebFileAttachment::WebFileAttachmentsController \<  
> > map.from\_plugin :web\_file\_attachment  
> > I’m using rails 2.1.1 and engines 2.0.0
> 
> The most obvious things are:
> 
> - if your controller is WebFileAttachment::WebFileAttachmentsController,  
> then it should be in a file called  
> vendor/plugins/web\_file\_attachment/app/controllers/web\_file\_attachment/web\_file\_attachments\_controller.rb

Maybe the documentation could be a bit clearer? The example at  
[http://api.rails-engines.org/classes/Engines/RailsExtensions/Routing.html](http://api.rails-engines.org/classes/Engines/RailsExtensions/Routing.html)  
puts ‘my\_pluign/’ in the controller route.

> - if your controller is WebFileAttachmentsController, then it should be in  
> a file called  
> vendor/plugins/web\_file\_attachment/app/controllers/web\_file\_attachments\_controller.rb

yes, you’re right, I misnamed the controller file. Thanks for pointing  
it out!

Raph

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [October 30, 2008, 12:24pm UTC](https://www.ruby-forum.com/t/routing-problem/152123/4 "2008-10-30T12:24:08Z")

</div>

On 30 Oct 2008, at 11:15, Raphael B. wrote:

> Maybe the documentation could be a bit clearer? The example at  
> [http://api.rails-engines.org/classes/Engines/RailsExtensions/Routing.html](http://api.rails-engines.org/classes/Engines/RailsExtensions/Routing.html)  
> puts ‘my\_pluign/’ in the controller route.

You’re absolutely right - that is confusing. I’ll change that to make  
it clearer.

Thanks!

James
