Skip to content

Instantly share code, notes, and snippets.

View jnwheeler44's full-sized avatar

Justin Wheeler jnwheeler44

View GitHub Profile
$ git confif --global help.autocorrect 1
git: 'confif' is not a git command. See 'git --help'.
Did you mean this?
config
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
def self.get_home_page_data(location, user)
sql = 'SELECT DISTINCT c.id, c.received_on, c.info, c.number, c.condition_id,
p.first_name, p.last_name, p.middle_initial, '
sql += ' rp.active, rp.viewed, rp.printed, rs.diagnosis_id '
describe Chair do
it 'gets home page data' do
# These wouldn't really be here
location = Factory.create(:location)
chair = Factory.create(:chair)
user = Factory.create(:user)
Chair.get_home_page_data(location, user).should include(chair)
end
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
def self.get_home_page_data(location, user)
# Looking at other spots in the code, I see that the individual fields
# aren't relevant, and the extra selected fields aren't referenced.
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
scope :with_active_viewed_report, joins(:report).where(:reports => {:active => 1, :viewed => 1})
scope :user_allowed, lambda { |user| where(:person_id => user.permission_owner_ids) }
# TODO: Remove location references; they aren't needed
class Result
def active_report
active_reports.first
end
def get_date_of_report
if active_report
active_report.date_reported.strftime('%m/%d/%Y ')
else
'No Report'
class Report
def date_reported_formatted(format='%m/%d/%Y ')
date_reported.strftime(format)
end
end
class NullReport
def method_missing(meth, *args)
"No Report"
end
git commit -m 'First I did this
> Then I did that
> Finally, I finished it'
@jnwheeler44
jnwheeler44 / gist:4530342
Last active December 11, 2015 02:28
Incorrect MySQL client library version! This gem was compiled for 5.5.27 but the client library is 6.0.0. (RuntimeError)
If you get this: "Incorrect MySQL client library version! This gem was compiled for 5.5.27 but the client library is 6.0.0. (RuntimeError)"
The error might be because of a conflicting mysql-connector-c package installed by homebrew.
brew uninstall mysql-connector-c
gem uninstall mysql2
bundle
@jnwheeler44
jnwheeler44 / console.js
Created January 21, 2013 16:17
jQuery console on page without jQuery
var script= document.createElement('script');
script.type= 'text/javascript';
script.src = "//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var $j = jQuery.noConflict();