Я пытаюсь связать с существующим маршрутом /clients/:client_id/invoices/:id
с моей страницы /clients/:client_id
show
и не могу работать, как сделать это.Не удается связать маршрут исправить с помощью link_to
У меня есть has_many through:
отношения и вот мои models
class Client < ActiveRecord::Base
has_many :invoices
has_many :items, through: :invoices
class Invoice < ActiveRecord::Base
belongs_to :user
belongs_to :client
has_many :items, :dependent => :destroy
accepts_nested_attributes_for :items, :reject_if => :all_blank, :allow_destroy => true
class Item < ActiveRecord::Base
belongs_to :invoice
belongs_to :client
Мои маршруты
resources :clients do
resources :invoices
end
resources :invoices
мои клиентские контроллеры показывают Действие
def show
@client = Client.find(params[:id])
@invoices = @client.invoices.build
end
И мои клиенты show.html.erb
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>Sender</th>
<th>Reciever</th>
<th>Amount</th>
<th>Currency</th>
<th>Date</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @client.invoices.each do |invoice| %>
<tr>
<td><%= invoice.sender %></td>
<td><%= invoice.reciever %></td>
<td><%= invoice.amount %></td>
<td><%= invoice.currency %></td>
<td><%= invoice.date %></td>
<td><%= link_to 'Show', invoices_path(@clients, @invoice) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
каждый раз, когда я нажимаю link_to show
он перенаправляет меня /invoices
Я перепробовал кучу разных link_to
форматов, но я не был в состоянии понять это.