Files
nairobi/app/models/budget/group.rb
rgarcia 0398bb23cb Consistent spacing
Temporarily… because there are 2 kinds of Ruby developers, those who
indent methods under `private` and does who don’t

https://gist.github.com/joefiorini/1049083#gistcomment-37692
2018-03-22 22:24:58 +01:00

25 lines
470 B
Ruby

class Budget
class Group < ActiveRecord::Base
include Sluggable
belongs_to :budget
has_many :headings, dependent: :destroy
validates :budget_id, presence: true
validates :name, presence: true, uniqueness: { scope: :budget }
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
def single_heading_group?
headings.count == 1
end
private
def generate_slug?
slug.nil? || budget.drafting?
end
end
end