petities/petitions.eu

View on GitHub
app/models/office.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class Office < ApplicationRecord
  default_scope { order('name ASC') }

  resourcify

  extend FriendlyId
  friendly_id :name, use: :slugged

  has_many :petitions

  belongs_to :organisation
  belongs_to :petition_type

  has_many :images, as: :imageable, dependent: :destroy
  accepts_nested_attributes_for :images

  scope :visible, -> { where(hidden: false) }

  def self.default_office
    find_by(email: 'nederland@petities.nl')
  end
end