2

I am absolutely new to Ruby and Rails and I am getting an error when running this command:

rails generate scaffold User name:string email:string

Here is the full error I am getting:

/Users/ad7863/rails_project/demo_app/config/application.rb:7: undefined method `groups' for Rails:Module (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/railties-3.0.11/lib/rails/commands.rb:15:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.11/lib/rails/commands.rb:15
from script/rails:6:in `require'
from script/rails:6

I am following the Ruby on Rails tutorial which can be found here.

I am using Rails version 3.0.11.

Anyone have any idea what I'm doing wrong?

Thanks.

Edit: the contents of my application.rb file:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module DemoApp
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

# Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'


end
end
  • Can you post rails_project/demo_app/config/application.rb? – ScottJShea Mar 14 '12 at 21:21
  • Yes, here: http://pastebin.com/WDEYaC05 – Artful Dodger Mar 14 '12 at 21:27
  • 1
    Best if you edit your original post and add it there – ScottJShea Mar 14 '12 at 21:28
  • Well this seems to be a similar error and unfortunately there was no resolution accepted: http://stackoverflow.com/questions/7463642/rails-undefined-method-groups-for-rails-module – ScottJShea Mar 14 '12 at 21:32
  • 1
    Off the top of my head I would update the Gemfile to remove the `gem 'rails', '3.0.11'` dependency and go with just `gem 'rails'` or `gem 'rails', >= '3.2'. Also, Michael Hartl has a very popular and up to date tutorial that might work better for you: http://ruby.railstutorial.org/chapters/static-pages – ScottJShea Mar 14 '12 at 21:36
  • That was my brother. He didn't manage to sort it out and then gave up completely. @ScottJShea I've tried what you've said, the second one gave me a syntax error and with gem 'rails' I get the same error as before. Also, that is the tutorial that I am using. – Artful Dodger Mar 14 '12 at 21:37
  • Well I grabbed the wrong link... here is his updated draft tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=3.2 – ScottJShea Mar 14 '12 at 21:55
  • Great, thanks. I'll give it a shot and let you know how it goes. **Edit:** seems to be working now with the new instructions. – Artful Dodger Mar 14 '12 at 21:58
  • Another tutorial that is a video tutorial but might work for you is Rails for Zombies: http://railsforzombies.org/ – ScottJShea Mar 14 '12 at 23:20

1 Answers1

0

On line 7 of your application.rb file, change:

Bundler.require(*Rails.groups(:assets => %w(development test)))

to:

# Bundler.require(*Rails.groups(:assets => %w(development test)))
lee
  • 2,351
  • 1
  • 16
  • 18