This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jobs_within(radius) | |
return [] unless location | |
jobs = [] | |
company.jobs.each do |j| | |
if j.location && j.location.distance_from(location) < (radius + location.radius) | |
jobs += j | |
end | |
end | |
return jobs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Clocker | |
@queue = :clock_queue | |
def self.perform(clock_id) | |
clock = Clock.find(clock_id) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):023:0> Time.zone | |
=> (GMT-08:00) Pacific Time (US & Canada) | |
irb(main):024:0> Time.zone.parse('3-23-2012') | |
ArgumentError: invalid date | |
from /usr/local/lib/ruby/1.9.1/date.rb:1691:in `new_by_frags' | |
from /usr/local/lib/ruby/1.9.1/date.rb:1736:in `parse' | |
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/values/time_zone.rb:271:in `rescue in parse' | |
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/values/time_zone.rb:271:in `parse' | |
from (irb):24 | |
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShiftsController < ApplicationController | |
load_and_authorize_resource | |
skip_load_resource :only => :index | |
# GET /shifts | |
def index | |
begin | |
start_date = Time.strptime( params[:from].to_s, '%m-%d-%Y') | |
rescue ArgumentError | |
start_date = 1.week.ago.beginning_of_day |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p290 :057 > 1.day.ago + 24.hours == Time.now.utc | |
=> false | |
ruby-1.9.2-p290 :058 > 1.day.ago + 24.hours == Time.now.utc | |
=> false | |
ruby-1.9.2-p290 :059 > 1.day.ago + 24.hours == Time.now.utc | |
=> false | |
ruby-1.9.2-p290 :060 > puts 1.day.ago + 24.hours, Time.now.utc | |
2012-02-10 04:21:24 UTC | |
2012-02-10 04:21:24 UTC | |
=> nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
params[:from] ||= "rubbish" | |
start_date = params[:from].to_datetime | |
rescue ArgumentError | |
start_date = 1.week.ago | |
params[:from] = start_date.strftime("%m/%d/%Y") | |
end | |
begin | |
params[:to] ||= "rubbish" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
start_date = params[:from].to_datetime | |
rescue ArgumentError | |
start_date = 1.week.ago | |
params[:from] = start_date.strftime("%m/%d/%Y") | |
end | |
begin | |
end_date = params[:to].to_datetime | |
rescue ArgumentError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file name: app/assets/javascripts/collections/entries.rb | |
class Raffler.Collections.Entries extends Backbone.Collection | |
url: '/api/entries' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="toolbar"> | |
<div class="left"> | |
<%= form_tag "", method: "get" do %> | |
<%= label_tag(:from, "From:") %> | |
<%= text_field_tag :from, params[:from], class: "datepicker" %> | |
<%= label_tag(:to, "to") %> | |
<%= text_field_tag :to, params[:to], class: "datepicker" %> | |
<%= submit_tag "Find" %> | |
<% end %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From <%= text_field_tag "from", params[:from], class: "datepicker" %> | |
to <%= text_field_tag "to", params[:to], class: "datepicker" %> |