我有一个关于指数再融资的链接
<%= link_to "View details", refinancing_path(@refinancing) %>
例如,这个 refinancing_path(@refinancing) 是 refinancings/6
我的路线很简单:
resources :refinancings, except: :destroy
我的控制器是:
def show
@refinancing = Refinancing.find(params[:id])
# THIS GET REFINANCING THROUGH HISTORIC REFINANCING
@hist_refin = HistoricRefinancing.consult_historic_refinancing(params[:refinancing_id])
end
这是历史性再融资的模型
class HistoricRefinancing < ActiveRecord::Base
belongs_to :authorization
has_many :refinancings
scope :consult_historic_refinancing, -> (refinancing_id) { HistoricRefinancing.where("refinancing_id = ? ", "#{refinancing_id}") }
我只需要在我的视图索引中单击链接_显示此授权的再融资详细信息。单击时我收到此错误:
No route matches {:action=>"show", :controller=>"refinancings", :id=>nil} missing required keys: [:id]
当然,没有 id,但是如何得到这个呢?请帮我!
更新 ######################################
我的观点节目是......
<h3>Details of refinancing</h3>
<p>
<strong>Name:</strong>
<%= @refinancing.employee.person.name %>
</p>
<p>
<strong>Period:</strong>
<%= @refinancing.period.strftime("%m/%Y") %>
</p>
<p>
<strong>Value</strong>
<%= number_to_currency @refinancing.value %>
</p>
只是这个...