Sha256: bd0ae1f17d4bb32555697b49bb8c91ad407b86c0098ae674c272a9a54388f4f6

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

class Item < ApplicationRecord
  has_many :furniture_items, inverse_of: :item
  has_many :furnitures, through: :furniture_items, inverse_of: :items, dependent: :destroy

  validates :name, uniqueness: { case_sensitive: false }, presence: true
  # validates :code, uniqueness: { case_sensitive: false }, presence: true

  before_save do
    self.code = name
  end

  rails_admin do
    navigation_label I18n.t(:main_records)
    navigation_icon 'fa fa-cube'
    weight 3

    field :name
    field :description

    list do
      scopes [:all, :starts_with_a, :starts_with_b, :starts_with_c, :starts_with_d, :starts_with_e, :starts_with_f, :starts_with_g, :starts_with_h, :starts_with_i, :starts_with_j, :starts_with_k, :starts_with_l, :starts_with_m, :starts_with_n, :starts_with_o, :starts_with_p, :starts_with_q, :starts_with_r, :starts_with_s, :starts_with_t, :starts_with_u, :starts_with_v, :starts_with_w, :starts_with_x, :starts_with_y, :starts_with_z ]
      field :updated_at
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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