This way we can simplify the code and don't have to rely on `.try` statements which are confusing and so we don't allow them in the `Rails/SafeNavigation` Rubocop rule.
10 lines
303 B
Ruby
10 lines
303 B
Ruby
class Budget
|
|
class ContentBlock < ApplicationRecord
|
|
validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
|
|
validates :heading, presence: true, uniqueness: { scope: :locale }
|
|
|
|
belongs_to :heading
|
|
delegate :name, to: :heading, allow_nil: true
|
|
end
|
|
end
|