问题
I'm still relatively new to Rails and Ruby - and after upgrading to the new version of Ubuntu (11.04), my rails installation is not working correctly. I've tried updating Rails, and updating the versions I have installed using RVM, none of which worked.
Here is the terminal output:
/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/alec/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/alec/.rvm/rubies/ruby-1.9.2-p180/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 <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/share/rails-ruby1.8/railties/bin/rails:14:in `<main>'
From that, I tried updating railties specifically, but that didn't work either. The output hasn't changed since I first received the error.
回答1:
The issue was that rails reverted back to 2.3.5. I had to uninstall rails and set up a gemset as described here: Every time I close terminal rails defaults back to 2.3.5 from 3.0.3?
回答2:
I'd recommend you take a look at RVM. It is by far the best way to manage installations of Ruby and Rails on the *NIX platforms.
来源:https://stackoverflow.com/questions/5849332/rails-is-broken-after-upgrading-to-ubuntu-11-04