Friday, December 13, 2013

Rails - Define class method in module file

module PicturePartials
module Cse

def self.included(base)
base.extend ClassMethods
end

module ClassMethods
def find_by_picture_id(picture_id)
Picture.joins(:picture).where('picture_id = ?', picture_id).first
end
end


end
end

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.