I''m writing a plugin that requires that an implementing Model has a
method called ''title'' defined.
For my init.rb, I have:
require ''article_assignable''
ActiveRecord::Base.send(:include, David::ArticleAssignable)
Then in article_assignable.rb:
module David
module ArticleAssignable
def self.included(base)
base.extend Plugin
end
module Plugin
def article_assignable
# Set-up polymorphic association
has_many :assignables, :as => :object
# Raise exception if the model doesn''t have a Title
attribute.
# Do this by checking for the `title` method.
raise "Requires Title method in #{self.class}" unless
respond_to?(:title)
end
end
end
end
The problem I''m getting is using `respond_to?`. It seems to be checking
`Class` rather than the Active Record model I have using:
class Film < ActiveRecord::Base
article_assignable
end
Any help would be much appreciated.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---