D
Daniel Waite
(The code I will demonstrate is Rails-based, but the question is
Ruby-based.)
I'm familiar with the following:
ActiveRecord::Base
Basically says, look inside ActiveRecord for a class or module named
Base.
But what about the following:
::Attachment
Does that basically say, no matter what scope you are in, jump to the
highest level to look for the class or module named Attachment?
The following code only works when I prefix the Attachment class with ::
has_one :attachment, :as => :attachable, :class_name => '::Attachment'
def assign_attachment=(attachment_id)
self.attachment = ::Attachment.find(attachment_id)
end
Ruby-based.)
I'm familiar with the following:
ActiveRecord::Base
Basically says, look inside ActiveRecord for a class or module named
Base.
But what about the following:
::Attachment
Does that basically say, no matter what scope you are in, jump to the
highest level to look for the class or module named Attachment?
The following code only works when I prefix the Attachment class with ::
has_one :attachment, :as => :attachable, :class_name => '::Attachment'
def assign_attachment=(attachment_id)
self.attachment = ::Attachment.find(attachment_id)
end