Skip to content

Instantly share code, notes, and snippets.

@somethvictory
Last active July 17, 2018 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somethvictory/83583af7ff718716db9989b35e51cf3b to your computer and use it in GitHub Desktop.
Save somethvictory/83583af7ff718716db9989b35e51cf3b to your computer and use it in GitHub Desktop.
class Robot < ApplicationRecord
validates :name, presence: true
validates :color, presence: true
belongs_to :color
belongs_to :shipment, optional: true
has_and_belongs_to_many :statuses
def should_be_recycled?
rusty? || loose_screews?
end
def rusty?
statuses.rusty.present?
end
def loose_screws?
statuses.loose_screws.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment