2011-09-18 3 views
0

Я использую Rails 3.1 с Authlogic 3.0.3. У меня есть приложение, развернутое на Heroku. Локально все работает прекрасно, однако, когда я раскрываю к Heroku я получаю следующее сообщение об ошибке:Ошибка аргументации на Heroku

ArgumentError (wrong number of arguments (3 for 2)): 
    app/controllers/application_controller.rb:38:in `current_user_session' 
    app/controllers/application_controller.rb:43:in `current_user' 
    app/controllers/application_controller.rb:5:in `block in <class:ApplicationController>' 

С более полной StackTrace:

vendor/plugins/rpm/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb:16:in `log_with_newrelic_instrumentation' 
.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:550:in `exec_query' 
.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:679:in `table_exists?' 
.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/attribute_methods/primary_key.rb:41:in `get_primary_key' 
.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/attribute_methods/primary_key.rb:25:in `reset_primary_key' 
.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/attribute_methods/primary_key.rb:16:in `primary_key' 
.bundle/gems/ruby/1.9.1/gems/authlogic-3.0.3/lib/authlogic/session/session.rb:48:in `session_credentials' 
.bundle/gems/ruby/1.9.1/gems/authlogic-3.0.3/lib/authlogic/session/session.rb:33:in `persist_by_session' 
.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:413:in `_run_persist_callbacks' 
.bundle/gems/ruby/1.9.1/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:81:in `run_callbacks' 
.bundle/gems/ruby/1.9.1/gems/authlogic-3.0.3/lib/authlogic/session/callbacks.rb:90:in `persist' 
.bundle/gems/ruby/1.9.1/gems/authlogic-3.0.3/lib/authlogic/session/persistence.rb:55:in `persisting?' 
.bundle/gems/ruby/1.9.1/gems/authlogic-3.0.3/lib/authlogic/session/persistence.rb:39:in `find' 
app/controllers/application_controller.rb:38:in `current_user_session' 
app/controllers/application_controller.rb:43:in `current_user' 
app/controllers/application_controller.rb:5:in `block in <class:ApplicationController>' 

Я установка Authlogic, как это показано в примерах, как Мне нужна простая проверка подлинности. Это код в моем ApplicationController:

class ApplicationController < ActionController::Base 
    protect_from_forgery 
    layout 'application' 
    before_filter { |c| Authorization.current_user = current_user } #this is line 5 

    helper_method :current_user, :current_user_session 

# erroneous stuff removed 

    private 
    def current_user_session 
    return @current_user_session if defined?(@current_user_session) 
    @current_user_session = UserSession.find #line 43 
    end 

    def current_user 
    return @current_user if defined?(@current_user) 
    @current_user = current_user_session && current_user_session.user #line 38 
    end 
end 

И мой UserSession:

class UserSession < Authlogic::Session::Base 
    find_by_login_method :find_by_anything 
end 

Что вызывает метод в пользователя:

class User < ActiveRecord::Base 
    attr_accessible :email, :password, :remember_me 

    acts_as_authentic do |c| 
    c.login_field = 'name' 
    c.require_password_confirmation = false 
    c.validates_format_of_login_field_options = {:with => /^[a-zA-Z0-9]+$/, :message => "should use only letters and numbers, no other characters."} 
    c.validates_length_of_login_field_options = {:within => 5..25} 
    end 

    def self.find_by_anything(login) 
    # Postgres and SQLite use a case sensitive search, so we need to make it case insensitive 
    find_by_smart_case_login_field(login) || find_by_email(login) 
    end 

Моя догадка, что UserSession.find является преступник, но я не могу для меня решить эту проблему. Я пробовал все в течение двух дней, но журналы не очень полезны, и я, похоже, не прохожу путь через исходный код. Единственное различие между средами локально я использую MySQL, а героку использует Postgres.

EDIT: вопрос не был афлогичным, это был NewRelic. Случилось так, что ошибка всплыла и стала очевидной благодаря Authlogic - см. Ответ для решения.

ответ

0

Оказывается, что аргумент ArgumentError был вызван аддон NewRelic. Если у вас возникла эта проблема, перейдите в командную строку и введите:

heroku addons:remove newrelic:standard --app your_app_name 

 Смежные вопросы

  • Нет связанных вопросов^_^