We forgot to add these changes to pull requests which were in development before we upgraded to Rails 5. We're also moving the rubocop rules to the basic files, so we're notified when we inherit from `ActiveRecord::Base`.
19 lines
723 B
Ruby
19 lines
723 B
Ruby
class DownloadSetting < ApplicationRecord
|
|
validates :name_model, presence: true
|
|
validates :name_field, presence: true
|
|
|
|
def self.initialize(model, field_name, config)
|
|
download_setting = DownloadSetting.find_by(name_model: model.name,
|
|
name_field: field_name,
|
|
config: config)
|
|
if download_setting.nil?
|
|
download_setting = DownloadSetting.create(downloadable: false,
|
|
name_model: model.name,
|
|
name_field: field_name,
|
|
config: config)
|
|
end
|
|
download_setting
|
|
end
|
|
|
|
end
|