내 프로젝트에서 '범위'를 사용하고 싶습니다.스코프에 상수가 없습니다. 제품입니까?
은 내가 'product.rb
module Scopes::Product
#TODO: change this to array pairs so we preserve order?
SCOPES = {
# Scopes for selecting products based on taxon
:taxon => {
:taxons_name_eq => [:taxon_name],
:in_taxons => [:taxon_names],
},
# product selection based on name, or search
:search => {
:in_name => [:words],
:in_name_or_keywords => [:words],
:in_name_or_description => [:words],
:with_ids => [:ids]
},
...
같은
파일'product.rb '몇 가지 방법을 포함, 내 모델에서 사용 참조 lib 디렉토리 아래의 폴더를 생성 '
include ::Scopes::Product
오류 메시지 :
pry(main)> Product
ArgumentError: Scopes is not missing constant Product!
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:479:in `load_missing_constant'
덕분에 회신했지만 작동 할 수 없다. 새로운 오류 LoadError를 참조하십시오 : Expected /home/tanglin/fincloud/lib/scopes/product.rb 제품 정의 파일의 이름을 바꾸고 일반 모듈을 사용하는 방법을 알고 있습니다. 그러나 나는 무엇이 '모듈 스코프 :: 제품'인지 이해하고 싶습니다. 어떻게 작동합니까? 소스 코드는 opensource의 'Spree' – ivanLee