undefined method `groups' for Rails:Module

后端 未结 4 949
慢半拍i
慢半拍i 2020-12-11 04:16

As usual I\'ve been an idiot and broken rails on my mac somehow. I think it all started when it said the version of rake wasn\'t recent enough so I delved down a huge road o

相关标签:
4条回答
  • The problem is that your app was generated with a version of rails 3.1 or higher. It's trying to call the "groups" method, which doesn't exist. If you haven't gotten too far, just start from scratch. Otherwise, create a dummy project and compare the config/application.rb files. Make them match.

    0 讨论(0)
  • 2020-12-11 05:01

    My error: I have the same error, as you can see here:

    $ rails c production
    config/application.rb:7: undefined method `groups' for Rails:Module (NoMethodError)
        from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21:in `require'
        from /usr/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:21
        from script/rails:6:in `require'
        from script/rails:6
    

    In config/application.rb file, I have these lines:

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

    Then I checked another Rails 3 app, in this app I checked again this file and it contains these lines:

    Bundler.require(:default, Rails.env) if defined?(Bundler)
    

    So I sustitute this line and I works.

    I hope to be your solution too.

    0 讨论(0)
  • 2020-12-11 05:04

    i think you have already found an answer to your questions? however by adding the source code listed below at the top of config/application.rb might help you.

    require 'rails/all'
    
    0 讨论(0)
  • 2020-12-11 05:09

    Read this article : http://ryan.mcgeary.org/2011/02/09/vendor-everything-still-applies/

    or

    TLDR bundle install --path vendor then bundle --binstubthen bin/rake whatever

    oh and don't forget to the .rvmrc in your app directory

    0 讨论(0)
提交回复
热议问题