How do I create a module that when included in a model will automatically add some relationships and named_scopes?
Here's what I've got right now:
module Resource
has_many(:permissions)
named_scope(
:acl_check,
lambda do |user_id, method| {
:include => :permission,
:conditions => [
["permissions.user_id=?", user_id],
["permissions.method=?", method],
["permissions.classname=?", self.class.name]
]
}
end)
end
Although I'm getting the following error when I try to start my server:
......config/initializers/Resources.rb:5: undefined method `named_scope' for Resource:Module (NoMethodError)
Thanks to all who respond! :)