簡體   English   中英

從1.8.7升級到1.9.2的Rails引入語法錯誤

[英]rails upgrade from 1.8.7 to 1.9.2 introduces syntax error

當前使用ruby-1.8.7-p302 [i386]

移至ruby ruby​​-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”上bar之以鼻,但是對於我來說,我看不到語法出了什么問題(特別是因為它在1.8.7中有效。

對helper_method的方法調用是錯誤的,helper_method(* meths)接受表示輔助名稱的可變數量的符號, 而不接受opts哈希值helper_method(* meths,opts = {})

# 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM