0

My Rails app suddenly stopped to work when i try to run migration. For example:

$ rails generate migration AddBalanceToUsers balance:float /Users/serg/.rvm/gems/ree-1.8.7-head/gems/rails-2.3.5/bin/../lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError) from /Users/serg/.rvm/gems/ree-1.8.7-head/gems/rails-2.3.5/bin/../lib/rails_generator/base.rb:90 from /Users/serg/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require' from /Users/serg/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require' from /Users/serg/.rvm/gems/ree-1.8.7-head/gems/rails-2.3.5/bin/../lib/rails_generator.rb:34 from /Users/serg/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require' from /Users/serg/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require' from /Users/serg/.rvm/gems/ree-1.8.7-head/gems/rails-2.3.5/bin/rails:14 from /Users/serg/.rvm/gems/ree-1.8.7-head/bin/rails:19:in `load' from /Users/serg/.rvm/gems/ree-1.8.7-head/bin/rails:19 

I use

ree 1.8.7 rails 2.3.5 (but i also have rails 3.2.3) RVM OS X Lion 
3
  • 1
    Check Similar issue:- stackoverflow.com/questions/5849332/… Commented Jul 6, 2012 at 11:16
  • @Shamithc I tried: 'gem uninstall rails' and then 'gem install rails -v=2.3.5' but i still have such problem Commented Jul 6, 2012 at 11:35
  • You can update rails to 2.3.8 and test. Commented Jul 6, 2012 at 12:06

2 Answers 2

1

Ok, i founded solution. In rails 2 we should generate migration via other way:

$ script/generate migration AddBalanceToUsers balance:float 

script/generate is the key.

Hope it'll help someone.

Sign up to request clarification or add additional context in comments.

Comments

1

I resolved this issue by following below steps :-

(1) First I checked by running ‘gem environment’

(2) Then I located the rails executable by :-
abc@ubuntu:~$ locate rails |grep -e "bin/rails$" /home/abc/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/bin/rails /usr/lib/ruby/vendor_ruby/railties/bin/rails

(3) I appended the path to ~/.bashrc by :-
abc@ubuntu:~$ echo 'export PATH=$PATH:/home/abc/.rvm/gems/ruby-1.9.3-0/gems/railties-.2.1/bin' >> ~/.bashrc

(4) Reload the ~/.bashrc file:-
abc@ubuntu:~$ . ~/.bashrc

And then when I ran the rails command, it created a new sample app perfectly :-)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.