Skip to content

Instantly share code, notes, and snippets.

Avatar

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
chrislerum / Supplier.rb
Last active Nov 25, 2017
Shouldn't includes give different sql?
View Supplier.rb
class Supplier < ApplicationRecord
has_many :supplier_results
end
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', 'tags.name']
end
end
View _daughter_fields.html.erb
<table>
<%= f.fields_for :daughters do |daughters_form| %>
<tr>
<td>
Daughter Name:
</td>
<td>
<%= daughters_form.text_field :name %>
</td>
<td>
View wordpress
server {
listen 81;
server_name sempermedusa.com/blog;
return 301 http://$server_name$request_uri;
}
View output.html
<tr>
<td class="my-label">
<input type="checkbox" name="user[role_ids][]" id="role_1" value="1" checked="checked" />
</td>
<td class="value">
<label for="role_1">Approver</label>
</td>
</tr>
View model.rb
module ActiveModel
class Errors
def full_messages
map do |attribute, message|
if attribute == :name
full_message(' ', message)
else
full_message(attribute, message)
end
end
View test result
rspec ./spec/models/video_spec.rb
.....F
Failures:
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[player.name.to_sym] = player.games.average(:score).to_i}
8 averages.max_by{|k,v| v}[0]
9 end