I'm a new Ruby/Rails guy. Here's one question puzzling me:
Can we find the exact module lists mixin-ed for a class in Rails from the API doc? For example, if we have an instance of one subclass of ActiveRecord::Base, we can use validates method in this class such as following:
class Product < ActiveRecord::Base
has_many :line_items
validates :title, :description, :image_url, :presence => true
end
from rails api doc we can find that validates belongs to ActiveModel::Validations::ClassMethods, so ActiveRecore::Base must have ActiveModel::Validations::ClassMethods mixin, but I didn't find anything relating to this in the api reference. Can anyone tell me if I can find this info from api doc?
Thanks for all of your help in advance. I really hope my question doesn't sound too silly:)
ActiveRecord::Base.ancestors
provides you with the list. And you can doActiveRecord::Base.ancestors.include? ActiveModel::Validations #=> true
– apneadiving