Skip to content

Instantly share code, notes, and snippets.


Chris Lerum chrislerum

View GitHub Profile
View bundler_output.txt
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
haml-rails was resolved to 0.9.0, which depends on
actionpack (>= 4.0.1)
kaminari was resolved to 0.17.0, which depends on
actionpack (>= 3.0.0)
lograge was resolved to 0.11.2, which depends on
actionpack (~> 5.2.4)
chrislerum / Supplier.rb
Last active November 25, 2017 02:01
Shouldn't includes give different sql?
View Supplier.rb
class Supplier < ApplicationRecord
has_many :supplier_results
View routes.rb
get 'videos/:id/coveritlive/enable', controller: 'coveritlive', action: :enable, as: :coveritlive_enable
get 'videos/:id/coveritlive/disable', controller: 'coveritlive', action: :disable, as: :coveritlive_disable
get 'videos/:id/coveritlive/reset', controller: 'coveritlive', action: :reset, as: :coveritlive_reset
get 'videos/:id/coveritlive/start', controller: 'coveritlive', action: :start, as: :coveritlive_start
get 'videos/:id/coveritlive/end', controller: 'coveritlive', action: :end, as: :coveritlive_end
View resulting json
how to structure builder so filter requires both hidden be false AND approved be true?
right now, 'approved' just replaces the 'hidden' line.
query = Jbuilder.encode do |json|
json.query do
json.multi_match do
json.query term
json.fields ['title^2', 'description', '']
View _daughter_fields.html.erb
<%= f.fields_for :daughters do |daughters_form| %>
Daughter Name:
<%= daughters_form.text_field :name %>
View wordpress
server {
listen 81;
return 301 http://$server_name$request_uri;
View output.html
<td class="my-label">
<input type="checkbox" name="user[role_ids][]" id="role_1" value="1" checked="checked" />
<td class="value">
<label for="role_1">Approver</label>
View model.rb
module ActiveModel
class Errors
def full_messages
map do |attribute, message|
if attribute == :name
full_message(' ', message)
full_message(attribute, message)
View test result
rspec ./spec/models/video_spec.rb
1) Video#last_used works with one video
Failure/Error: expect(Video.last_used.usec).to eq video.updated_at.usec
expected: 840199
got: 0
View class method on Player to return player with best average game score
5 def self.top_player
6 averages = {}
7 joins(:games).group(:id).each {|player| averages[] =}
8 averages.max_by{|k,v| v}[0]
9 end