Files
openfoodnetwork/app/models/producer_property.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

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