# Route Problem

**URL:** <https://www.ruby-forum.com/t/route-problem/174135>\
**Category:** Rails\
**Created:** [August 21, 2009, 6:15am UTC](https://www.ruby-forum.com/t/route-problem/174135 "2009-08-21T06:15:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [August 21, 2009, 6:15am UTC](https://www.ruby-forum.com/t/route-problem/174135/1 "2009-08-21T06:15:56Z")

</div>

So I’m trying to start up my first rails app in quite a while (since  
1.5) and I’m getting the following error:

/Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action\_controller/  
routing/builder.rb:159:in `build': undefined method`[]’  
for :comments:Symbol (NoMethodError)

Obviously it doesn’t like something about my attempts at RESTful  
routing:

```
    map.resources :start, :only => :index

```

map.resources :jobs do |job|  
map.jobs :comments  
end  
map.resources :cities, :only =\> [:new, :edit]  
map.resources :regions, :only =\> [:new, :edit]  
map.resources :countries, :only =\> [:new, :edit]  
map.resources :companies do |company|  
map.company :jobs, :only =\> :show  
end  
map.resources :departments, :only =\> [:new, :edit, :destroy]

I’m not sure what is wrong though. According to the docs I’ve found  
this syntax is correct.

---

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [August 21, 2009, 9:21am UTC](https://www.ruby-forum.com/t/route-problem/174135/2 "2009-08-21T09:21:25Z")

</div>

Hi,  
I think your problem may sit in your block, because you create a  
variable ‘job’  
So change from map.jobs to map.job

Glen wrote:

> So I’m trying to start up my first rails app in quite a while (since  
> 1.5) and I’m getting the following error:
> 
> /Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action\_controller/  
> routing/builder.rb:159:in `build': undefined method`[]’  
> for :comments:Symbol (NoMethodError)
> 
> Obviously it doesn’t like something about my attempts at RESTful  
> routing:
> 
> ```
> map.resources :start, :only => :index
> 
> ```
> 
> map.resources :jobs do |job|  
> map.jobs :comments  
> end  
> map.resources :cities, :only =\> [:new, :edit]  
> map.resources :regions, :only =\> [:new, :edit]  
> map.resources :countries, :only =\> [:new, :edit]  
> map.resources :companies do |company|  
> map.company :jobs, :only =\> :show  
> end  
> map.resources :departments, :only =\> [:new, :edit, :destroy]
> 
> I’m not sure what is wrong though. According to the docs I’ve found  
> this syntax is correct.

---

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [August 21, 2009, 12:28pm UTC](https://www.ruby-forum.com/t/route-problem/174135/3 "2009-08-21T12:28:08Z")

</div>

> map.resources :jobs do |job|  
> map.jobs :comments  
> end

Hi change this to

map.resources :jobs do |job|  
job.resources :comments  
end

> map.resources :companies do |company|  
> map.company :jobs, :only =\> :show  
> end

Change this to

map.resources :companies do |company|  
company.resources :jobs, :only =\> :show  
end

Sijo

---

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [August 21, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/route-problem/174135/4 "2009-08-21T15:06:55Z")

</div>

On Aug 21, 4:28 am, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > map.resources :companies do |company|  
> > –  
> > Posted viahttp://www.ruby-forum.com/.

Thanks guys, that was embarrassing. I should know at least that much  
ruby.
