Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 701
user537072 Avatar asked Feb 22 '26 07:02

user537072


2 Answers

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

like image 134
brad Avatar answered Feb 23 '26 20:02

brad


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
like image 31
Paul Schreiber Avatar answered Feb 23 '26 21:02

Paul Schreiber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!