在经过数月的旧代码重新使用之后,才开始从头开始构建一个rails项目。新项目不允许我从命令行运行rails服务器。我收到错误报告问题在application.rb文件中
rails_projects/platform/config/application.rb:7: undefined method `groups' for Rails:Module (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
application.rb文件如下所示:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module Platform
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
end
end
答案 0 :(得分:1)
Rails.groups
方法是在Rails 3.1中添加的。从它看起来,你仍然使用Rails 3.0.9。将Gemfile中Rails的版本号更改为3.1.1
并运行bundle update rails
以解决此问题。