Sha256: b47f47b3a8d9c0c5b4da12071b460d75d637f2e771163782b4f036a803a29c2d

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

module LatoMedia
  class Doc::CellsController < Doc::DocController

    def elements_preview
      set_random_media
    end

    def elements_previews
      set_random_medias(10)
    end

    def inputs_media
      set_random_media
    end

    def inputs_gallery
      set_random_medias(10)
    end

    private

    def set_random_media
      medias = LatoMedia::Media.all

      if medias.empty?
        @media = LatoMedia::Media.new
      else
        @media = medias.sample
      end
    end

    def set_random_medias(qnt)
      @medias = []
      medias = LatoMedia::Media.all
      qnt.times do
        media = medias.sample
        media = LatoMedia::Media.new unless media
        @medias.push(media)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lato_media-2.1.2 app/controllers/lato_media/doc/cells_controller.rb
lato_media-2.1 app/controllers/lato_media/doc/cells_controller.rb