mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
18 lines
464 B
Ruby
18 lines
464 B
Ruby
class ProducerProperty < ActiveRecord::Base
|
|
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
|