# Newbie RESTful routing problem, please help!

**URL:** <https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597>\
**Category:** Rails\
**Created:** [February 17, 2010, 4:11am UTC](https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597 "2010-02-17T04:11:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [February 17, 2010, 4:11am UTC](https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597/1 "2010-02-17T04:11:56Z")

</div>

Hello, on my last post a few weeks ago, all who replied seemed to agree  
that the problem I was having was in my routing configuration. I  
decided to read up a bit on rails routing using this article:

> **[rails.info](http://guides.rails.info/routing.html)**
>
> Ruby on Rails,Rails Tutorial,Ruby Basics,Rails 4,Bar Rails,Rail

I decided to try what the article calls RESTful routing. So I set my  
model:

class Receta \< ActiveRecord::Base  
end

I set up my controller:

class RecetaController \< ApplicationController  
def index

end

end

And I set up my view (which I generated along with my controller:

# Receta#index

Find me in app/views/receta/index.html.erb

I then set up my routing in routes.rb as follows:

map.resources :recetas

I got an error with the following full trace:

C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active\_support/dependencies.rb:443:in  
`load_missing_constant' C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const\_missing\_with\_dependencies’  
C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active\_support/dependencies.rb:92:in  
`const_missing' C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize’  
C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active\_support/inflector.rb:360:in  
`each' C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize’  
C:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active\_support/core\_ext/string/inflections.rb:162:in  
`constantize' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:443:in `recognize’  
C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/routing/route\_set.rb:436:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch’  
C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/dispatcher.rb:121:in  
`_call' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build\_middleware\_stack’  
C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/query\_cache.rb:29:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:34:in  
`cache' C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache’  
C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/query\_cache.rb:28:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/string\_coercion.rb:25:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/session/cookie\_store.rb:93:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/reloader.rb:34:in  
`run' C:/jruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call’  
C:/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/adapter/rails.rb:133:in  
`call' C:/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/handler/grizzly.rb:55:in `call’

I then tried setting up my routing like this:

map.resources :receta

And it worked. Can someone please clarify why with :recetas it didn’t  
work? What difference does it make to declare a resource with an “s” at  
the end. Any info will be greatly appreciated. Thanks in advance.

Note: I removed the default routes for both attempts.

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [February 17, 2010, 6:23am UTC](https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597/2 "2010-02-17T06:23:16Z")

</div>

The convention is that controllers are plural, so instead of…

class RecetaController \< ApplicationController

you should have…

class RecetasController \< ApplicationController

note the plural form of Recetas

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [February 17, 2010, 9:45am UTC](https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597/3 "2010-02-17T09:45:44Z")

</div>

your controller should be:

class RecetasController \< ApplicationController  
def index  
end  
end

not:

class RecetaController \< ApplicationController

åœ¨2010-02-17?11:11:56ï¼Œ"tuti?plain"?[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)?å†™é“ï¼š

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [February 18, 2010, 1:43am UTC](https://www.ruby-forum.com/t/newbie-restful-routing-problem-please-help/183597/4 "2010-02-18T01:43:01Z")

</div>

tuti plain wrote:

> C:/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/adapter/rails.rb:133:in  
> `call' C:/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/handler/grizzly.rb:55:in`call’
> 
> I then tried setting up my routing like this:
> 
> map.resources :receta
> 
> And it worked. Can someone please clarify why with :recetas it didn’t  
> work? What difference does it make to declare a resource with an “s” at  
> the end. Any info will be greatly appreciated. Thanks in advance.
> 
> Note: I removed the default routes for both attempts.

Try this:

map.resources :recetas, :controller =\> “receta”
