您可以帮我吗?我被困!如何将自定义参数添加到路由中的默认操作
我为模型“Customer”实现了单个表继承。 “人”和“公司”是“客户”。所以我加了两条新航线转发所有请求到CustomersController
:
resources :customers # added by generator
resources :people, :controller => 'customers' <== NEW
resources :companies, :controller => 'customers' <== NEW
我想要做的就是
- 参数“
type
”添加到资源的作用“new
”:customers
- 在两个其他资源中添加默认值“Person”和“Company”到“type”参数(如果参数被继承!?)
我的目标是能够调用
new_customer_path(:type => 'Person')
和
new_person_path
我以前试过以下,但它的工作
resources :people, :controller => 'customers' do
get 'new', :on => :member, :type => 'Person'
end
能否停止其它动作(如显示)那里有人告诉我我的错误?
你要约束或简单的参数? – apneadiving
我认为一个简单的参数应该做。任何建议的约束? – Hiasinho