だから私はこの質問( Railsモデルを作成するときの構文エラー)に出くわしました。これには私のものと似たエラーがあります。私の問題はRuby 1.9ではなくRuby 1.8を使用していることにあると推測しています。回答の1つで説明されているように、gemをアンインストールしてrubygemsを更新しようとしましたが、問題は解決しませんでした。また、rvm を介してデフォルトの ruby を 1.9 に設定しようとしました - 動作しますが、問題は解決しません。
「gem env」を実行すると、次のようになります。
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/owner/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
usr/bin には、usr/bin/ruby1.9.1 へのシンボリック リンクである「ruby」があります。
基本的に、ここで使用されているルビーを変更する方法を知る必要があります (少なくとも私の問題は解決すると思います)。
私のOSはLinux Mint 12です.Rails --versionは「Rails 3.2.3」を返します
私の完全なエラーは以下のとおりです(プロジェクトディレクトリで「rails s」を実行した場合):
=> 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
/usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load': /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_sample_app_session'
^
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:588
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:587
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config/environment.rb:5
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:4:in `require'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:4
from /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:1:in `new'
from /media/Windows/Users/Owner/Projects/rails_projects/sample_app/config.ru:1
私の宝石ファイルは次のとおりです。
source 'https://rubygems.org'
gem 'rails'
gem 'bootstrap-sass'
gem 'tilt'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails'
gem 'guard-rspec', '0.5.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'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'rspec-rails'
gem 'capybara', '1.1.2'
# System-dependent gems# Test gems on Windows
group :test do
gem 'rspec-rails'
gem 'capybara', '1.1.2'
gem 'rb-fchange', '0.0.5'
gem 'rb-notifu', '0.0.4'
end
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
end
group :production do
gem 'pg', '0.12.2'
end
道:
echo $PATH /usr/bin/rubycurrent:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ユーザー/ゲーム
「どのルビー」が返す:
/usr/bin/rubycurrent/ruby