0
我已經API設置是這樣的:葡萄:動態前綴?
class Dashboard < Api
def self.inherited(subclass)
super
subclass.instance_eval do
prefix 'dashboard'
#...
end
end
def self.company_id(path)
':company_id' + path
end
helpers do
def current_company
@current_company ||= Company.find(params[:company_id]) if params[:company_id]
end
end
end
問題:我繼承Employee
類從Dashboard
,我想達到的目標:資源,從Dashboard
繼承,應該可以訪問由它的命名空間'/dashboard/companies/:company_id/employees'
,與current_company
工作正確。
我覺得每次都挺累提供的,而不是namespace
方便全路線:
get 'companies/:company_id/employees'
#...
end
但是,這不會給需要的結果:
namespace :companies do
namespace :employees do
...
end
end