簡體   English   中英

ArgumentError,create操作中的參數數目錯誤(2為0),在Heroku上有效,但在本地服務器上無效

[英]ArgumentError, wrong number of arguments (2 for 0) in create action, works on Heroku but not on local server

我最近有一個第三方為我開發的RoR應用程序,現在我自己添加自己想要的未來功能。 它可以在Heroku上運行,但是當我嘗試在localhost:3000上運行它時,出現ArgumentError。 我沒有更改任何代碼,只是從github提取了代碼,並嘗試在本地開發服務器上運行它以實現新的更改。 我已經問過他們這個問題,但是他們不確定原因,所以這里...

我們正在運行ruby 1.9.2,rails 3.0.7

每當我嘗試將項目保存到我的網站上時,或者每當在對象上調用.save時,我都會收到ArgumentError,參數數量錯誤(2表示0)。

應用程序跟蹤

app/controllers/users/projects_controller.rb:24:in `create'

全跡

activesupport (3.0.7) lib/active_support/ordered_hash.rb:16:in `block in to_yaml'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:19:in `call'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:19:in `block in quick_emit'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:296:in `dump_coder'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:61:in `accept'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:36:in `<<'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:165:in `dump'
activerecord (3.0.7) lib/active_record/base.rb:1720:in `block in arel_attributes_values'
activerecord (3.0.7) lib/active_record/base.rb:1713:in `each'
activerecord (3.0.7) lib/active_record/base.rb:1713:in `arel_attributes_values'
activerecord (3.0.7) lib/active_record/persistence.rb:265:in `create'
activerecord (3.0.7) lib/active_record/timestamp.rb:47:in `create'
activerecord (3.0.7) lib/active_record/callbacks.rb:277:in `block in create'
activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_create_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:277:in `create'
activerecord (3.0.7) lib/active_record/persistence.rb:246:in `create_or_update'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `block in create_or_update'
activesupport (3.0.7) lib/active_support/callbacks.rb:424:in `_run_save_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `create_or_update'
activerecord (3.0.7) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.7) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block (2 levels) in save'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7)     lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block in save'
activerecord (3.0.7) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.7) lib/active_record/transactions.rb:239:in `save'
app/controllers/users/projects_controller.rb:24:in `create'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.7) lib/active_support/callbacks.rb:448:in `_run__334044120__process_action__677517956__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:493:in `call'
warden (1.0.6) lib/warden/manager.rb:35:in `block in call'
warden (1.0.6) lib/warden/manager.rb:34:in `catch'
warden (1.0.6) lib/warden/manager.rb:34:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in   `call'
actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.4) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.7)    lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.4) lib/rack/sendfile.rb:106:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.7) lib/rails/application.rb:168:in `call'
railties (3.0.7) lib/rails/application.rb:77:in `method_missing'
railties (3.0.7) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-  p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-  p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in  `block in start_thread'

來自projects_controller的代碼,第24行是if語句

def create
    @project = Project.new(params[:project])
    @project.memberships.build(:user_id => current_profile.id, :pending => false)

    if @project.save
      redirect_to destination, :notice => 'Project was successfully created.'
    else
      build_project_associations_for_nested_forms
      render :action => 'new'
    end
   end

我對此有些新意,所以我不確定要確定問題還需要什么。

您是否嘗試過運行除WEBrick以外的其他功能(假設您正在使用該功能)? 嘗試安裝Thin(gem安裝Thin),然后查看問題是否仍然存在。

確保已獲取所有必需的gem,然后運行bundle install:

bundle install

重新啟動應用程序,希望能有所幫助。

暫無
暫無

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

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