Module: Decidim::TranslatableAttributes

Overview

A set of convenience methods to deal with I18n attributes and validations in a way that is compatible with AttributeObject and ActiveModel, thus making it easy to integrate into Rails’ forms and similar workflows.

Instance Method Summary collapse

Instance Method Details

#attachment?(value) ⇒ Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/decidim/translatable_attributes.rb', line 131

def attachment?(value)
  value.is_a?(String) && value.include?(ActiveStorage.routes_prefix)
end

#default_locale?(locale) ⇒ Boolean

Returns:

  • (Boolean)


126
127
128
129
# File 'lib/decidim/translatable_attributes.rb', line 126

def default_locale?(locale)
  locale.to_s == try(:default_locale).to_s ||
    locale.to_s == try(:current_organization).try(:default_locale).to_s
end