破坏导轨环境:无法运行导轨生成脚手架

时间:2012-02-20 18:26:06

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1

我有一个谜:我的rvm / ruby​​-1.9.2环境,运行rails 3.1.3,无法运行此命令     rails生成脚手架游戏名称:string difficulty:string

“方法丢失”失败后,我得到以下转储

kenb@stargate:~/development/sudoku$ rails g scaffold Game name:string difficulty:string
      invoke  active_record
/home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/base.rb:1088:in `method_missing': undefined method `mass_assignment_sanitizer=' for ActiveRecord::Base:Class (NoMethodError)
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/railtie.rb:59:in `block (3 levels) in <class:Railtie>'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/railtie.rb:58:in `each'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/active_record/base.rb:2190:in `<top (required)>'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/generators/named_base.rb:165:in `pluralize_table_names?'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/generators/named_base.rb:112:in `table_name'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.3/lib/rails/generators/active_record/model/model_generator.rb:17:in `create_migration_file'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:269:in `block in _invoke_for_class_method'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/shell.rb:74:in `with_padding'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:258:in `_invoke_for_class_method'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:150:in `_invoke_from_option_orm'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/generators.rb:168:in `invoke'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands/generate.rb:12:in `<top (required)>'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /home/kenb/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:28:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我已经删除了rvm和所有依赖的gem,重新安装rvm,ruby-1.9.2,然后在我的app文件夹中运行'bundle install'。一切顺利。然后,我在generate命令上失败了。

1 个答案:

答案 0 :(得分:1)

根据http://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/mass_assignment_sanitizer%3D mass_assignment_sanitizer是在rails 3.2中引入的,而你使用的是3.1.3。你没有用rails 3.2生成项目吗?