Why do I get error “undefined method `write_inheritable_attribute'” in my migration?

情到浓时终转凉″ 提交于 2019-12-24 20:39:39

问题


I attempted to generate a migration like:

rails generate migration RemovefromGenotypes box:integer well:string

but then I get this error:

/usr/share/rails-ruby1.8/railties/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
    from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:90:in `<class:Base>'
    from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:85:in `<module:Generator>'
    from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:48:in `<module:Rails>'
    from /usr/share/rails-ruby1.8/railties/lib/rails_generator/base.rb:6:in `<top (required)>'
    from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/share/rails-ruby1.8/railties/lib/rails_generator.rb:34:in `<top (required)>'
    from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/caseyr/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/share/rails-ruby1.8/railties/bin/rails:14:in `<main>'

I have no clue where to start to debug this, but would certainly appreciate it if anyone could point me in the right direction...

Thanks! --rick


回答1:


I have same issue. Use following command and problem gone

 gem install rails

This will install updated rails and all thing working find again.




回答2:


Happened to me while installing rails 2.3.14 after rails 3.2.6

It seems rails 2.3 overwrites some rails 3 files. Fixed by removing 2.3 and reinstalling 3.2



来源:https://stackoverflow.com/questions/10906472/why-do-i-get-error-undefined-method-write-inheritable-attribute-in-my-migrat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!