Call a specific gem helper inside a model

153 views Asked by At

I need to use the imgix-rails gem inside a project.

I need to call an helper inside a model, this helper:

require "imgix"
require "imgix/rails/tag"
require "imgix/rails/image_tag"
require "imgix/rails/picture_tag"

module Imgix
  module Rails
    module ViewHelper
      include UrlHelper

      def ix_image_tag(source=nil, path, tag_options: {}, url_params: {}, srcset_options: {})
        return Imgix::Rails::ImageTag.new(path, source: source, tag_options: tag_options, url_params: url_params, srcset_options: srcset_options).render
      end

      def ix_picture_tag(source=nil, path, tag_options: {}, url_params: {}, breakpoints: {}, srcset_options: {})
        return Imgix::Rails::PictureTag.new(path, source: source, tag_options: tag_options, url_params: url_params, breakpoints: breakpoints, srcset_options: srcset_options).render
      end
    end
  end
end

I cannot find a way to call ix_image_tag.

0

There are 0 answers