Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

undefined method `groups' for Rails:Module

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 of different gems etc. and different versions of rails, I ended up getting rails from github but it replaces it with the most recent version.

Now I fear all of my configuration files are incorrect, but when I try to 'rake rails:update' I get the following error with a trace:

rake aborted!
undefined method `groups' for Rails:Module
/Users/jamielawrence/Documents/Websites/JaphexPortfolio/config/application.rb:8
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
/Users/jamielawrence/Documents/Websites/JaphexPortfolio/Rakefile:4
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:78:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:61:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/bin/rake:32
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

I've pretty much had enough tonight, I've been down a million routes (it all started with trying to get an authentication add on to work).

All i want to do is reset the config files to what they were originally for rails 3.0.9, my gem file went from:

gem 'rails', '3.0.9'

to

gem 'rails', :git => 'git://github.com/rails/rails.git'

back to

gem 'rails', '3.0.9'

...I'm an idiot...but an idiot with a huge headache.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...