Sha256: 5b18e732e8cd33963a885756fa906765c084157f7dfcb3810c6d35d6fba22cb5

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

# == Schema Information
#
# Table name: formats_items
#
#  id                 :integer          not null, primary key
#  title_translations :hstore           default({})
#  notes_translations :hstore           default({})
#  category_id        :integer
#  created_at         :datetime
#  updated_at         :datetime
#
module Formats
  class Item < ActiveRecord::Base
    belongs_to :category, class_name: 'Formats::Category'

    translates :title, :notes

    has_one :icon, as: :assetable, dependent: :destroy
    fileuploads :icon

    class << self
      def sunrise_search(params)
        q = all
        q = q.where('title LIKE ?', "%#{params[:title]}%") if params[:title].present?
        q = q.where(category_id: params[:category_id]) if params[:category_id].present?
        q
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/models/formats/item.rb