0
Ruby on Rails應用程序在開發中工作,但在Heroku中崩潰。在應用程序中,我將值放入一個結構體(Selection)中,然後將其加載到數組(@selections)中,以便在屏幕上選擇下拉窗口。我找到了導致此錯誤的行,請參閱rails代碼和Heroku日誌中的print語句,但不知道如何解決此問題。已嘗試了一些替代品,但迄今沒有運氣。當我在我的gemfile中指定ruby版本(ruby'1.9.3')時,我的理解是Heroku會使用此版本的Ruby(例如,不是由不同版本的Ruby引起的錯誤)。將struct分配給在開發中工作的數組,但不在Heroku上
任何幫助讚賞 感謝 皮埃爾
鑽取控制器
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
我也嘗試使用紅寶石「@ selections.push(Selection.new(index,company_name,u.id,false))」,我使用IRB檢查了很好,但是這個在Heroku中沒有用。 – user1854802