Sha256: 7eb1be576b17e3cb74192de1f4a67d2706efb3c3faf9b7520f64791ca44f46b9
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
class Furniture < ApplicationRecord has_many :chosen_furnitures, inverse_of: :furniture has_many :chosen_rooms, through: :chosen_furnitures, inverse_of: :furnitures, dependent: :destroy has_many :furniture_items, inverse_of: :furniture has_many :items, through: :furniture_items, inverse_of: :furnitures, dependent: :destroy # accepts_nested_attributes_for :furniture_items, allow_destroy: true validates :name, uniqueness: { case_sensitive: false, scope: :description }, presence: true validates :code, uniqueness: { case_sensitive: false }, presence: true after_save { chosen_furnitures.each do |cr| Rails.logger.debug "SAVING: #{cr.inspect}" cr.save end } amoeba do enable include_association :furniture_items prepend :name => "Copia di " prepend :code => "Copia di " end def display_name "#{name} (#{description})" end rails_admin do navigation_label I18n.t(:main_records) navigation_icon 'fa fa-cubes' weight 2 field :name field :code field :description field :items 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/furniture.rb |