2013-07-05 44 views
-2

我正在開發我的應用程序時突然出現一個錯誤,在控制檯中彈出。創建Rails回調錯誤,保存在控制檯中

使用Rails控制檯時,我無法創建,也無法保存模型。這是錯誤我得到:

rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418: syntax error, unexpected '=', expecting ')' 
       result = result = _callback_before_71 

我恢復到以前的承諾在git的,它仍然無法正常工作......

完整的錯誤消息:

SyntaxError: /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418: syntax error, unexpected '=', expecting ')' 
       result = result = _callback_before_71 
        ^
/Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:423: syntax error, unexpected keyword_end, expecting ')' 
/Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:426: syntax error, unexpected keyword_end, expecting ')' 
/Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:427: syntax error, unexpected $end, expecting ')' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:400:in `class_eval' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:400:in `__run_callback' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_validate_callbacks' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activemodel-3.2.11/lib/active_model/validations.rb:228:in `run_validations!' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activemodel-3.2.11/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:403:in `_run__1438787982741389732__validation__2895348434256153547__callbacks' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activemodel-3.2.11/lib/active_model/validations/callbacks.rb:53:in `run_validations!' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activemodel-3.2.11/lib/active_model/validations.rb:195:in `valid?' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/validations.rb:69:in `valid?' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/validations.rb:77:in `perform_validations' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/validations.rb:50:in `save' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_methods/dirty.rb:22:in `save' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:259:in `block (2 levels) in save' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:311:in `with_transaction_returning_status' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:259:in `block in save' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:270:in `rollback_active_record_state!' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/transactions.rb:258:in `save' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/persistence.rb:45:in `create' 
    from (irb):3 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start' 
    from /Users/justindomingue/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>'1.9.3-p374 
+0

任何特定型號或所有型號?很高興看到與此相關的一些應用程序代碼。 – deefour

+1

你可以發佈你用來保存的線嗎? – NicoSantangelo

回答

0

今晚我跑到同樣的問題,所以我要猜測導致你的問題的代碼。我的假設是,你未能保存的模型使用has_secure_password類方法。根據我的經驗,當您嘗試在臨時「密碼」字段上執行預定義的驗證(validates_presence_of,validates_length_of等)時,您會遇到上述錯誤。當我切換到類似於blog post中的使用推薦的驗證時,錯誤消失了。

希望這可以幫助你。