아래 코드에서 외부에서 reserved_words
에 어떻게 액세스합니까? FriendlyId::Reserved::Configuration.instance_variable_get(:reserved_words)
이렇게하는 것은 나에게 다음과 같은 오류를 제공외부에서 모듈의 attr_accessor 변수를 호출하는 방법?
module FriendlyId
module Reserved
module Configuration
attr_accessor :reserved_words
end
end
end
:
NameError: 'reserved_words' is not allowed as an instance variable name
특별히 'attr_accessor'가 필요합니까, 아니면 레일즈가'mattr_accessor'를 제공하는 확장 기능을 사용할 수 있습니까 (http://api.rubyonrails.org/classes/Module.html#method-i-mattr_accessor) – Shadwell
시험해보세요 :: FriendlyId :: Reserved :: Configuration.instance_variable_get (: reserved_words) – Egalitarian
이 스레드를 확인하십시오 http://stackoverflow.com/questions/185573/what-is-mattr-accessor-in-a-rails-module – xlembouras