Sha256: 30cb8d666da077abeb1663fdd2689de4e18d0f9260094962447a59060ebaa219

Contents?: true

Size: 614 Bytes

Versions: 1

Compression:

Stored size: 614 Bytes

Contents

# == Schema Information
#
# Table name: areas
#
#  id         :integer          not null, primary key
#  project_id :integer          not null
#  name       :string(255)
#  created_at :datetime
#  updated_at :datetime
#

class Area < ActiveRecord::Base
  belongs_to :project
  has_many :finishes
  has_many :deadlines

  validates :name, presence: true, uniqueness: { scope: :project_id },
    length: { maximum: 255 }
  validates :project, presence: true

  def last_for_project?
    project.areas.where("areas.id != ?", id).count == 0
  end

  def have_dependents?
    finishes.any? || deadlines.any?
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
self_systeem-0.1.0 test/dummy_app/app/models/area.rb