在对旧代码进行了数月的重新利用之后,刚刚开始从头开始构建rails项目。新项目不允许我从命令行运行rails服务器。我得到一个错误报告的问题是在应用程序。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
应用程序。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
Rails.groups
方法是在Rails 3.1中添加的。从外观上看,您仍然在使用Rails 3.0.9。将Gemfile中Rails的版本号更改为3.1.1
,然后运行bundle update rails
来解决这个问题。