Hi all
I’m a bit unsure about the caching with ||= …
I have the following code
class Member < ActiveRecord::Base
def allowed_to?(right, model)
# Setup owned system rights if not already done
unless @owned_system_rights
setup_owned_system_rights
else
raise "asdf"
end
...
end
private
def setup_owned_system_rights
@owned_system_rights = {}
system_groups.each do |system_group|
system_group.system_rights.each do |system_right|
@owned_system_rights[system_right.model_class.to_sym] = {}
unless @owned_system_rights[system_right.model_class.to_sym]
@owned_system_rights[system_right.model_class.to_sym][system_right.name.to_sym]
= true
end
end
end
end
I’d expect the raise “asdf” to be reached some time, but it’s not.
What’s wrong here?
Thanks, Josh