My application has deals which have orders. In my admin area I want to be able to process the orders manually.
In my access/deals view
<%= link_to "Process Orders", "Not sure what I put here?" %>
in my access/deals_controller
def process_orders
@deals = Deal.find(params[:id]
@orders = @deals.orders.where("state" == ?, "pending")
@orders.each do |order|
#order processing code here
end
end
How should I structure my link_to method to call the process_orders method in my admin/deals controller?
I thought something like
<%= link_to "Process Orders", access_deal_path(deal) %>
which give me the following url
localhost:3000/access/deals/9
how do I get something like
localhost:3000/access/deals/9/process_orders
I'm also open to suggestions on moving the processing_orders method to model or helper if that is a better way of doing this.
My excerpt of my routes file.
resources :deals do
resources :orders
end
namespace "access" do
resources :deals, :podcasts, :pages, :messages
end