This is kind of complicated. But I have namespaced routes, and this form is taking care of Customer model that is shared by two different controllers.
my routes:
namespace "self_service" do
resources :customers
my lousy attempt at instantiated an edit form
= form_for [:self_service, @current_customer], action: 'update', method: :put do |f|
my controller
class SelfService::CustomersController < SelfService::BaseController
layout 'self_service'
def edit
end
def update
end
end
This instantiation does 2 things that are wrong :
The url for the form is
/customers/146/self_service
. But shouldn't it be the other way around? Shouldn't it beself_service/customers/146/
?When I click submit, I get a
No route matches "/customers/146/self_service"
Update
As it turns out, this.. :
resources :customers do
member do
get :self_service
..contradicts this :
namespace "self_service" do
resources :customers
end
But what bothers me here is.. why should they contradict each other? One should be :
customers/:id/self_service
and the other is :
self_service/customers/:id