0

Ruby on rails 应用程序正在开发中,但在 Heroku 中崩溃。在应用程序中,我将值放在一个结构(Selection)中,然后我将其加载到一个数组(@selections)中,以便在屏幕上进行下拉窗口选择。我找到了导致此错误的行,请参阅 rails 代码和 Heroku 日志中的打印语句,但不知道如何修复它。已经尝试了许多替代方案,但到目前为止没有运气。当我在我的 gemfile 中指定一个 ruby​​ 版本(ruby '1.9.3')时,我的理解是 Heroku 将使用这个版本的 Ruby(例如,错误不是由不同版本的 Ruby 引起的)。

任何帮助感谢皮埃尔

钻控制器

Selection = Struct.new(:id, :name, :table_index, :user_valuation)

class DrillsController < ApplicationController
  before_filter :current_user
  before_filter :load_drill, except: [:index, :new, :create]
  …..
  def load_evaluation_assumption_selections
    load_stake
    @selections = []
    list_of_companies = []
    index = 0   
    @resource_estimations = @drill.resource_estimations
    if @resource_estimations.present?
      @resource_estimations.each do |u|
        unless list_of_companies.include?(u.company_id)
          list_of_companies.push(u.company_id)
          if u.company_id == @stake.company_id
            company_name = "default"
          else
            company_name = u.company.name
          end
          puts "ZZZZZ - before load struct, Selection, to array @selections"
          @selections += [Selection.new(index, company_name, u.id, false)] 
          puts "ZZZZZ - after load struct, Selection,  to array @selections"          
          index += 1
        end
      end
    end

Heroku 日志

2013-10-17T05:18:23.714529+00:00 app[web.2]:   Rendered stakes/_drill_interests.html.erb (3.3ms)
2013-10-17T05:18:23.714529+00:00 app[web.2]:   Rendered stakes/_form.html.erb (21.0ms)
2013-10-17T05:18:23.714529+00:00 app[web.2]:   Rendered resource_estimations/_edit_multiple.html.erb (19.5ms)
2013-10-17T05:18:23.714529+00:00 app[web.2]:   Rendered drills/edit.html.erb within layouts/application (72.2ms)
2013-10-17T05:18:23.721851+00:00 heroku[router]: at=info method=GET path=/drills/9/edit host=quiet-fortress-3338.herokuapp.com    fwd="203.45.50.22" dyno=web.2 connect=1ms service=102ms status=304 bytes=0
2013-10-17T05:18:23.714529+00:00 app[web.2]: Completed 200 OK in 92ms (Views: 65.6ms | ActiveRecord: 15.4ms)
2013-10-17T05:18:26.140463+00:00 app[web.2]: Started GET "/drills/9/investor" for 203.45.50.22 at 2013-10-17 05:18:26 +0000
2013-10-17T05:18:26.169417+00:00 app[web.2]: ZZZZZ - before load struct, Selection, to array @selections
2013-10-17T05:18:26.173260+00:00 app[web.2]: 
2013-10-17T05:18:26.173260+00:00 app[web.2]: ArgumentError (wrong number of arguments (4 for 1)):
2013-10-17T05:18:26.173260+00:00 app[web.2]:   app/controllers/drills_controller.rb:232:in `new'
2013-10-17T05:18:26.173260+00:00 app[web.2]:   app/controllers/drills_controller.rb:232:in `block in load_evaluation_assumption_selections'
2013-10-17T05:18:26.173260+00:00 app[web.2]:   app/controllers/drills_controller.rb:223:in `load_evaluation_assumption_selections'
2013-10-17T05:18:26.173260+00:00 app[web.2]:   app/controllers/drills_controller.rb:59:in `investor'
2013-10-17T05:18:26.173260+00:00 app[web.2]: 
2013-10-17T05:18:26.173260+00:00 app[web.2]: 
2013-10-17T05:18:26.174044+00:00 app[web.2]: Processing by DrillsController#investor as HTML
2013-10-17T05:18:26.174044+00:00 app[web.2]:   Parameters: {"id"=>"9"}
2013-10-17T05:18:26.174044+00:00 app[web.2]: Completed 500 Internal Server Error in 23ms
2013-10-17T05:18:26.171782+00:00 heroku[router]: at=info method=GET path=/drills/9/investor host=quiet-fortress-3338.herokuapp.com fwd="203.45.50.22" dyno=web.2 connect=1ms service=37ms status=500 bytes=643
4

1 回答 1

0

我放弃了尝试对菜单选择选项使用结构并改用哈希。皮埃尔

于 2013-10-21T23:40:25.500 回答