mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
20 lines
494 B
Ruby
20 lines
494 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ProducerProperty < ApplicationRecord
|
|
belongs_to :producer, class_name: 'Enterprise', touch: true
|
|
belongs_to :property, class_name: 'Spree::Property'
|
|
|
|
default_scope { order("#{table_name}.position") }
|
|
|
|
def property_name
|
|
property&.name
|
|
end
|
|
|
|
def property_name=(name)
|
|
if name.present?
|
|
self.property = Spree::Property.find_by(name: name) ||
|
|
Spree::Property.create(name: name, presentation: name)
|
|
end
|
|
end
|
|
end
|