BathHacked/energy-sparks

View on GitHub
app/models/subject.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# == Schema Information
#
# Table name: subjects
#
#  created_at :datetime         not null
#  id         :bigint(8)        not null, primary key
#  name       :string           not null
#  updated_at :datetime         not null
#

class Subject < ApplicationRecord
  has_and_belongs_to_many :activity_types, join_table: :activity_type_subjects
  scope :by_name, -> { order(name: :asc) }

  def i18n_key
    "#{self.class.model_name.i18n_key}.#{name.parameterize.underscore}"
  end
end