Skip to content

Instantly share code, notes, and snippets.

@somethvictory
Last active July 17, 2018 15:01
Show Gist options
  • Select an option

  • Save somethvictory/83583af7ff718716db9989b35e51cf3b to your computer and use it in GitHub Desktop.

Select an option

Save somethvictory/83583af7ff718716db9989b35e51cf3b to your computer and use it in GitHub Desktop.

Revisions

  1. somethvictory revised this gist Jul 17, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion robot.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    class Robot < ApplicationRecord

    validates :name, presence: true
    validates :color, presence: true

  2. somethvictory revised this gist Jul 17, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion robot.rb
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@ class Robot < ApplicationRecord

    has_and_belongs_to_many :statuses


    def should_be_recycled?
    rusty? || loose_screews?
    end
  3. somethvictory created this gist Jul 17, 2018.
    23 changes: 23 additions & 0 deletions robot.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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