mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
19 lines
601 B
Ruby
19 lines
601 B
Ruby
class Machine < ActiveRecord::Base
|
|
extend FriendlyId
|
|
friendly_id :name, use: :slugged
|
|
|
|
has_one :machine_image, as: :viewable, dependent: :destroy
|
|
accepts_nested_attributes_for :machine_image, allow_destroy: true
|
|
|
|
has_many :machine_files, as: :viewable, dependent: :destroy
|
|
accepts_nested_attributes_for :machine_files, allow_destroy: true
|
|
|
|
has_and_belongs_to_many :projects, join_table: 'projects_machines'
|
|
|
|
has_and_belongs_to_many :trainings, join_table: 'trainings_machines'
|
|
|
|
validates :name, presence: true, length: { maximum: 50 }
|
|
validates :description, presence: true
|
|
|
|
end
|