On 19/04/2010, at 2:15 PM, Sven Schott wrote:
> class TimeResource < ActiveRecord::Base
> self.abstract_class = true
> alias_method :can_be_modified_by?, :can_be_created_by?
> def can_be_created_by?(user)
> self.user.id == user
> end
> end
I think you need to but the alias_method call after the def.
class TimeResource < ActiveRecord::Base
self.abstract_class = true
def can_be_created_by?(user)
self.user.id == user
end
alias_method :can_be_modified_by?, :can_be_created_by?
end
def and alias_method are "executed" when the class is being read, and in your
first example can_be_created_by? wouldn't have been defined yet.
--
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en.