RoR新手在这里,感谢任何帮助。
我有以下错误:
undefined method `to_i' for :funding_level:Symbol
我正在尝试将funding_level和investment_id参数从link_to 传递到我的控制器中的新方法中。
据我了解,100 值作为符号而不是对象传递,当我尝试将其分配给整数变量@funding_level时会导致问题。
谢谢!
HTML:
<div id="investment-status">
<%= link_to "$100", new_project_funding_path(funding_level: 100,investment_id: @project.id), class: 'btn' %>
</div>
控制器:
def new
@investment = Project.find(params[:investment_id])
@funding_offered = :funding_level
@project_funding = current_user.project_fundings.new(investment: @investment, funding_offered: @funding_offered)
end