运行rails服务器的问题

时间:2012-09-02 15:18:21

标签: ruby-on-rails ruby

我刚在Mac OSX 10.7.4上使用Rails安装程序安装了rails env。

我使用“rails new”命令创建一个项目。

当我尝试运行“rails server”命令时,我收到此消息:

/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/options.rb:32:in `default_options': undefined method `write_inheritable_attribute' for Rails::Generator::Base:Class (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:90:in `<class:Base>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:85:in `<module:Generator>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:48:in `<module:Rails>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator/base.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/lib/rails_generator.rb:37:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-2.3.14/bin/rails:15:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/rails:23:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/rails:23:in `<main>'

当我运行$ ruby​​ -v和$ gem -v时,我分别得到“ruby 1.9.3p194”和“1.8.24”。我在这里错过了什么?如何让这台服务器运行?

2 个答案:

答案 0 :(得分:4)

看起来你正试图在Rails 2.3中使用Rails 3.x命令。在3.0版之前,您必须使用服务器脚本。

从您的应用程序目录中运行:

./script/server 

答案 1 :(得分:0)

将rails安装为gem gem install rails。当您使用rvm时,此处显示的文件夹路径显示rails 2.3.4,而您尝试运行rails server。检查/更改gem文件中的rails版本,然后执行bundle install。