Sha256: 82c78d5082bd5303288052eaec73cd32f36bd716eaec7629c2b98c0ec7e90dd8

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class Bundle < ApplicationRecord
  belongs_to :commission, inverse_of: :bundles
  has_many :chosen_items, inverse_of: :bundle, dependent: :nullify

  validates :commission, presence: true
  validates :code, presence: true, uniqueness: { case_sensitive: false, scope: :commission_id }

  # Items: I need a method to obtain all the items in the
  # current selected Commission
  def records_for_print
    # TODO: move away from this pseudo code as soon as Bancolini tells me
    # what Mobilart wants
    # chosen_item.name
    # chosen_item.barcode
    # chosen_item.timetables.last.status
    # chosen_item.timetables.last.job_type
    ChosenItem.joins(:bundle).where(bundles: {id: id}).distinct
  end

  def display_name
    [commission.code, code].compact.join(" - ")
  end

  rails_admin do
    navigation_label I18n.t("admin.tools.label")
    navigation_icon 'fa fa-dropbox'
    weight 9

    configure :id do
      visible false
    end
    configure :created_at do
      visible false
    end
    configure :updated_at do
      visible false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobilart_models-1.2.14 app/models/bundle.rb