app/models/task.rb
def needs_doing
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last #use find method
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
      if self.done
        return false
      elsif (self.kind == "Hourly") && (hours_since >= 1)
        return true
      elsif (self.kind == "Daily") && (self.right_time)
        return true
      elsif (self.kind == "Weekly") && ((self.right_time && self.right_day) || self.delayed_day)
        return true
      else
        return false
      end
    else
      return false
    end
  end
#delayed tasks show up with a 'needs doing' tag in their location
delayed tasks show up with a 'needs doing' tag in their location
delayed tasks show up with a ' needs doing ' tag in their location
def needs_doing
    @last_completion = ShiftsTask.find_all_by_task_id(self.id).select{|st| st.task_id == self.id}.last 
    if @last_completion
      hours_since = (Time.now - @last_completion.created_at)/3600
      hours_since_scheduled = (Time.now)
      if self.done
        return false
      elsif (self.kind == "Hourly") && (hours_since >= 1)
        return true
      elsif (self.kind == "Daily") && (self.right_time)
        return true
      elsif (self.kind == "Weekly") && ((self.right_time && self.right_day) || self.delayed_day)
        return true
      else
        return false
      end
    else
      return false
    end
  end
def needs_doing @last_completion = ShiftsTask . find_all_by_task_id ( self . id ) . select { | st | st . task_id == self . id } . last if @last_completion hours_since = ( Time . now - @last_completion . created_at ) / 3600 hours_since_scheduled = ( Time . now ) if self . done return false elsif ( self . kind == "Hourly" ) && ( hours_since >= 1 ) return true elsif ( self . kind == "Daily" ) && ( self . right_time ) return true elsif ( self . kind == "Weekly" ) && ( ( self . right_time && self . right_day ) || self . delayed_day ) return true else return false end else return false end end
delayed tasks show up with a 'needs doing' tag in their location
delayed tasks show up with a ' needs doing ' tag in their location
#use find method