我已经使用本指南在我的MacOS X中安装了RoR http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
这是我的版本:
$ ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
$ rails --version
Rails 3.2.3
$ gem --version
1.8.23
我无法运行我的应用,因此我使用本教程Google搜索并修改了Gemfile:http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
现在这是我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
当我使用
运行应用程序时rails server
我明白了:
=> Booting WEBrick
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load': /Users/giacomo/websrc/rubyrails-app/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_rubyrails-app_session'
^
from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:588
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/giacomo/websrc/rubyrails-app/config/environment.rb:5
from /Users/giacomo/websrc/rubyrails-app/config.ru:4:in `require'
from /Users/giacomo/websrc/rubyrails-app/config.ru:4
from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /Users/giacomo/websrc/rubyrails-app/config.ru:1:in `new'
from /Users/giacomo/websrc/rubyrails-app/config.ru:1
我该如何解决这个问题?
答案 0 :(得分:4)
使用Ruby 1.9.x而不是1.8.7。
或者打开/Users/giacomo/websrc/rubyrails-app/config/initializers/session_store.rb
并替换:
key: '_rubyrails-app_session'
使用:
:key => '_rubyrails-app_session'
打开/Users/giacomo/websrc/rubyrails-app/config/initializers/wrap_parameters.rb
并替换:
wrap_parameters format: [:json]
使用:
wrap_parameters :format => [:json]
答案 1 :(得分:2)
发生错误是因为新的ruby有另一种hash语法。您使用的教程已过时,我建议您尝试这样做:http://railsapps.github.com/installing-rails.html 这是我能找到的最好的。而且它也在不断更新。
在您的情况下,您只需要安装新版本的ruby,然后重新安装rails。