I have these routes
resources :brokers do
patch :approve
rake routes
broker_approve PATCH /brokers/:broker_id/approve(.:format) brokers#approve
PATCH /brokers/:id(.:format) brokers#update
The URL is http://localhost:3000/brokers/1/approve
.
It gives error
Couldn't find Broker with 'id'=
The controller which loads the broker is
def set_broker
@broker = Broker.find(params[:id])
The parameters are
{"_method"=>"patch", "authenticity_token"=>"O8jztBqgRPcepes/p6IQqTfUQ==", "broker_id"=>"1"}
How can I use the path /brokers/:id/approve
like how #update
does so it can use the same method to load the model?
Guide: http://guides.rubyonrails.org/routing.html#nested-resources