【发布时间】:2016-03-17 22:39:26
【问题描述】:
这让我很困惑,
我有 2 个模型 client has_many :invocies 和 invoice belongs_to client,
我将我的root 设置为索引所有invoices 和invoices 也可以通过clients show 视图访问。我的invoice show view 中有一个后退按钮,它链接回invoice 所属的client:id
返回链接表单发票/显示
<%= link_to 'Back', client_path(@invoice.client), class: "btn btn-primary" %>
这很好,但是从根路径启动invoice show 然后单击back 并重新定向到client show 视图真的很尴尬。有没有办法回到 root_path 或在 if 语句中显示 2 个按钮,并根据用户首先启动 invoice show view 的方式显示一个?完全卡住了。
这是我的路线文件
resources :invoices, only: [:new, :create, :destroy, :index]
resources :clients do
resources :invoices, shallow: true
end
root 'invoices#index'
【问题讨论】:
标签: ruby-on-rails routes link-to