내가 모델 Equipment::Feature
을 네임 스페이스 내 관리 부분 Admin::Equipment::FeaturesController
에서 컨트롤러를 네임 스페이스했다. 모델은 일반적이며 :admin
네임 스페이스 및 공개 웹 사이트에서 사용됩니다.레일 3 네임 스페이스가 모델과 컨트롤러 라우팅 문제
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
네임 스페이스
namespace :admin do
namespace :equipment do
resources :features
end
end
에 대한 라우팅을 설정했습니다. 내가 /admin/equipment/features
를 해결하지만 그것이 내가 Admin::Equipment
네임 스페이스를 선언 할 때까지이 일을하는 것 않았다
def index
@features = Equipment::Feature.all
end
처럼
Admin::Equipment::FeaturesController
보이는 내에서
uninitialized constant Admin::Equipment::FeaturesController::Equipment
예외
#index
조치를 던졌습니다. 이
Admin::EquipmentFeaturesController
같았다 전에 나는이 네임 스페이스 충돌의 일종 것 같다,하지만 난 그것을 얻을하지 않습니다 - 그것은 어디에서 오는가?
미리 감사드립니다.
UPDATEFeature
모델은 문제가 해결 아래에 답변을 당 #index
조치를 고정
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 (STI 패턴을 사용). 새로운 코드 :
def index
@features = ::Equipment::Feature.all
end
기능 모델의 코드를 표시하십시오. –
질문이 업데이트되었습니다. 'Feature' 모델은 STI 패턴을 사용하고 레일 컨벤션 – paulus