user537072
user537072

Reputation: 33

Rails3 routes problem: undefined method `resources'

I have installed Rails version 3.0.3, and now I have problems with my routes.rb file.

routes.rb:1: undefined method `resources' for main:Object (NoMethodError)

Where the problem can be?

resources :plains

That's all in my routes.rb

Upvotes: 2

Views: 2830

Answers (2)

brad
brad

Reputation: 32355

Given a routes file like this:

MyApp::Application.routes.draw do
  # Put resources here
end

You need to declare your resources inside that block, is that what you've done?

Your error saying resources is not a member of object, which leads me to believe you've made that declaration outside this block, as inside this block, you're in the scope of the app's routes, and resources is a method of that object.

Full code post would help though.

edit given that the error is on line 1 of that file, this is definitely what you've done, place it in the block

Upvotes: 7

Paul Schreiber
Paul Schreiber

Reputation: 12599

If that's the entirety of routes.rb, you'll need to add a block around it:

MyAppName::Application.routes.draw do
   resources :plains
end

Upvotes: 5

Related Questions