undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)

后端 未结 6 829
深忆病人
深忆病人 2020-12-15 22:52

I am working on rails, suddenly rails server stops working. It\'s working fine and I have used following command [platform windows 7]

gem install -v=2.3.5 ra         


        
6条回答
  •  猫巷女王i
    2020-12-15 23:22

    (@jeremy-f and @alex-villa are on the right track to identifying the problem itself.)

    The problem here is that the rails ... command in Rails version 2 is a generator, equivalent to rails new ... in Rails 3+. So rails s is a Rails 2 command to generate a new Rails 2 app called "s" (whereas most of us when we write rails s intend the Rails 3 usage, i.e. start a server!)

    If you install a gem, it will usually install its binary in the path, so you should be able to cause this error by doing gem install rails -v 2.3.15 then rails s as the OP says.

    Three ways to fix it:

    • gem install rails to install a newer version of Rails (you may have to specify a version >= 3.0)
    • Run the app with bundle exec rails s (only if you have Rails 3 in your Gemfile)
    • The usual way to run a Rails 2 project is simply script/server

提交回复
热议问题