Route Problem

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.

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.

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

On Aug 21, 4:28 am, Sijo Kg [email protected] 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.