내가 lib/
디렉토리에, 누구 엔진이 레일 엔진 설정과 같은 구성 파일이 못해 : 당신 넣다구성 값은 4.1.9
# Default configration for groups, roles and permissions
class Xaaron::Configuration
# What is the memeber group name?
attr_accessor :member_group
# What is the memeber role name?
attr_accessor :member_role
# What is the admin group name?
attr_accessor :admin_group
# What is the admin role name?
attr_accessor :admin_role
# What is the can read permission name?
attr_accessor :can_read
# What is the can create permission name?
attr_accessor :can_create
# What is the can edit permission name?
attr_accessor :can_edit
# What is the can delete permission name?
attr_accessor :can_destroy
# Should we push this data to black bird? False by default.
attr_accessor :push_to_black_bird
# Defaults are set here.
def initialize
@member_group = 'Member'
@admin_group = 'Administrator'
@member_role = 'Member'
@admin_role = 'Administrator'
@can_read = 'can_read'
@can_create = 'can_create'
@can_edit = 'can_edit'
@can_destroy = 'can_destroy'
@push_to_black_bird = false
end
end
당신은 내가 기본값을 설정 한 볼 수 있듯이을, 이것들을 바꾸기로 결정하지 마라.
admin_group = Xaaron::Group.create(:group_name => Xaaron.config.admin_group, :can_alter => false, :can_delete => false)
을 그리고 의도, 우리가 Administrator
이 그룹 이름으로 설정되어 있는지 보는 바와 같이 작동합니다 : 이제이 엔진 seed.rb
파일에 내가 좋아하는 뭔가를 할 수 있어요.
Xaaron.configure do |config|
config.push_to_black_bird = true
end
하지만 응용 프로그램을 부팅 할 때, 내가 가지고 :
`block in <top (required)>': undefined method `push_to_black_bird=' for #<Xaaron::Configuration:0x007fbc6b305988> (NoMethodError)
정말이 있습니까 각각의 논문에 대해 집합을 정의하고 방법을 얻는가? 유사한 구성으로 다른 구성 파일을 보았습니다.
당신이'configure' 방법 코드를 공유 주시겠습니까? 도움이 될 것입니다. – markets
@market, 나? 그것의'Xaaron :: Configuration' 클래스. 'Xaaron.configuration'이 필요합니까? 그렇다면 왜 내 씨앗이 효과가 있니? 왜냐하면''Xaaron.config.admin_group'을 실행하면 엔진과 엔진이 마운트 된 app에''Administrator ''가 생깁니다. – TheWebs
Ruby에서'attr_accessor'는 getter와 setter를 정의하므로 사용자가 할 필요가 없습니다 그들을 정의하십시오. 요점은이'configure' 메쏘드가하는 것을 보는 것입니다. 예제 코드 : https://github.com/markets/invisible_captcha/blob/master/lib/invisible_captcha.rb#L26-L28. 예제 사용법 : https://github.com/markets/maily#initialization-and-configuration – markets