2011-12-22 79 views
1

目前使用紅寶石1.8.7-P302 [I386]導軌從升級到1.8.7 1.9.2介紹語法錯誤

移動紅寶石紅寶石1.9.2-P0 [I386]

運行軌3.0.0

得到了升級後出現以下錯誤:

# RAILS_ENV=production rails s 
=> Booting WEBrick 
=> Rails 3.0.0 application starting in production on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
Exiting 
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:53:in `class_eval': /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:54: syntax error, unexpected tLBRACE (SyntaxError) 
     def {:only=>:after_sign_in_path_for}(*args, &blk) 
      ^
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:54: syntax error, unexpected '(', expecting $end 
     def {:only=>:after_sign_in_path_for}(*args, &blk) 
              ^
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:53:in `block in helper_method' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:52:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/helpers.rb:52:in `helper_method' 
from /var/www/html/matcha/app/controllers/application_controller.rb:8:in `<class:ApplicationController>' 
from /var/www/html/matcha/app/controllers/application_controller.rb:1:in `<top (required)>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in `load_dependency' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:346:in `require_or_load' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:491:in `load_missing_constant' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:183:in `block in const_missing' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `const_missing' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/devise-1.5.3/app/controllers/devise/confirmations_controller.rb:1:in `<top (required)>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in `load_dependency' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:346:in `require_or_load' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:300:in `depend_on' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:216:in `require_dependency' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:137:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:137:in `block in eager_load!' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:135:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/engine.rb:135:in `eager_load!' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/railties.rb:11:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/railties.rb:11:in `all' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:107:in `eager_load!' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `instance_exec' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:25:in `run' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:50:in `block in run_initializers' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `each' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/initializable.rb:49:in `run_initializers' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:134:in `initialize!' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/application.rb:77:in `method_missing' 
from /var/www/html/matcha/config/environment.rb:5:in `<top (required)>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
from /var/www/html/matcha/config.ru:3:in `block in <main>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize' 
from /var/www/html/matcha/config.ru:1:in `new' 
from /var/www/html/matcha/config.ru:1:in `<main>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:35:in `eval' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/builder.rb:35:in `parse_file' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:162:in `app' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:253:in `wrapped_app' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.4/lib/rack/server.rb:204:in `start' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/server.rb:65:in `start' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:30:in `block in <top (required)>' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:27:in `tap' 
from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:27:in `<top (required)>' 
from script/rails:6:in `require' 
from script/rails:6:in `<main>' 

相關application_controller代碼:

class ApplicationController < ActionController::Base 
    include Facebooker2::Rails::Controller 
    helper :all # include all helpers, all the time 
    protect_from_forgery 
    layout :layout_by_resource 
    before_filter :set_cache_buster 
    before_filter :current_facebook_user, :only => :after_sign_in_path_for 
    helper_method :current_facebook_client, :only => :after_sign_in_path_for 
    ... 
end 

它在「helper_method:current_facebook_client,:only =>:after_sign_in_path_for」上出現過,但是對於我的生活,我看不到語法有什麼問題(尤其是因爲它在1.8.7中工作。

+0

嘗試升級到最新的1.9.2或1.9.3 – rwilliams 2011-12-22 06:22:54

+0

爲什麼helper_method「only」在after_sign_in_path_for ...之後存在...這是一種方法。你不應該只有=>:after_sign_in_path_for – drhenner 2011-12-22 06:38:35

回答

1

的方法調用是helper_method是錯誤的,是helper_method(* meths)接受表示輔助名稱,它採取OPTS散列是helper_method符號的可變的量(* meths,選擇採用= {})

# from http://api.rubyonrails.org/ 

helper_method(*meths) 
# Declare a controller method as a helper. For example, the 
# following makes the current_user controller method available to the view: 

class ApplicationController < ActionController::Base 
    helper_method :current_user, :logged_in? 

    def current_user 
    @current_user ||= User.find_by_id(session[:user]) 
    end 

    def logged_in? 
    current_user != nil 
    end 
end 
+0

順便說一句,如果你要升級紅寶石,我建議使用紅寶石1.9.2-p290而不是-p0,這裏有很多修復。 – sunkencity 2011-12-22 07:09:27

+1

如果他升級了,那麼他可能升級到1.9.3-p0,據說Rails啓動時間有很多加速。或者在該版本和Rails出現任何新問題的同時? – 2011-12-22 08:06:27

+0

我還沒有試過1.9.3,所以我不能擔保,但是,聽起來很合理。 – sunkencity 2011-12-22 08:13:21