嵌套资源 - 如何传递所需的密钥和属性以进行更新?

时间:2012-11-07 16:58:50

标签: ruby-on-rails

我的嵌套资源正在用于form_for更新,但是我需要设置几个切换来更改状态字段。所以我使用link_to,并访问url helper。

   link_to "toggle", edit_project_expense_path(@project[:id],expense_item[:id])

的routes.rb

 resources :projects do
    resources :expenses
  end

  match '/submit_expense/:id' => 'expenses#submit_expense', :as => 'submit_expense'

rake routes

edit_project_expense GET    /projects/:project_id/expenses/:id/edit(.:format) expenses#edit

我的问题是:我怎样才能发送:approval_status =“1”,带有我的link_to?

1 个答案:

答案 0 :(得分:3)

  link_to "toggle", edit_project_expense_path(@project[:id],expense_item[:id], approval_status: 1)