我有名稱空間模型Equipment::Feature
和命名空間控制器在我的管理部分Admin::Equipment::FeaturesController
。模型是通用的,用於從:admin
命名空間和公共網站。我已經設置了路由的:admin
和:equipment
命名空間Rails 3名稱空間模型和控制器路由問題
namespace :admin do
namespace :equipment do
resources :features
end
end
這給了我以下路線:
admin_equipment_features GET /admin/equipment/features(.:format) admin/equipment/features#index
POST /admin/equipment/features(.:format) admin/equipment/features#create
new_admin_equipment_feature GET /admin/equipment/features/new(.:format) admin/equipment/features#new
edit_admin_equipment_feature GET /admin/equipment/features/:id/edit(.:format) admin/equipment/features#edit
admin_equipment_feature GET /admin/equipment/features/:id(.:format) admin/equipment/features#show
PUT /admin/equipment/features/:id(.:format) admin/equipment/features#update
DELETE /admin/equipment/features/:id(.:format) admin/equipment/features#destroy
漂亮的標準的東西。但是,當我解決/admin/equipment/features
它拋出我Admin::Equipment::FeaturesController
看起來像
def index
@features = Equipment::Feature.all
end
它似乎工作,直到我宣佈Admin::Equipment
命名空間uninitialized constant Admin::Equipment::FeaturesController::Equipment
例外
#index
行動。之前它就像Admin::EquipmentFeaturesController
我想這是某種命名空間碰撞,但我不明白它 - 它從哪裏來的?
在此先感謝!
UPDATEFeature
模型(使用STI模式)
class Equipment::Feature < ActiveRecord::Base
attr_accessible :category_id, :name_en, :name_ru, :type
belongs_to :category, :class_name => 'Equipment::Category'
has_many :item_features, :class_name => 'Equipment::ItemFeature'
has_many :items, :through => :item_features
translates :name
end
class FeatureBoolean < Equipment::Feature
end
class FeatureNumeric < Equipment::Feature
end
class FeatureString < Equipment::Feature
end
class FeatureRange < Equipment::Feature
end
UPDATE2 固定#index
行動,每回答以下解決了這個問題。新代碼:
def index
@features = ::Equipment::Feature.all
end
請顯示您的功能模型中的代碼。 –
更新的問題。 'Feature'模型使用STI模式,並按照Rails慣例 – paulus