Added interface and methods for edit the name of a Budget::Group if the budget is still inthe drafting phase
This commit is contained in:
@@ -10,14 +10,27 @@ class Budget
|
||||
validates :name, presence: true, uniqueness: { scope: :budget }
|
||||
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
|
||||
|
||||
scope :by_slug, ->(slug) { where(slug: slug) }
|
||||
|
||||
before_save :strip_name
|
||||
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
|
||||
def single_heading_group?
|
||||
headings.count == 1
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_slug?
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def strip_name
|
||||
self.name = self.name.strip
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user