This file contains 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 Player { | |
constructor() { | |
this._health = 20 | |
} | |
playTurn(warrior) { | |
considerMovement(warrior) | |
} | |
} |
This file contains 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 ArticlesController < ApplicationController | |
def index | |
@articles = Article.all | |
end | |
end |
This file contains 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 World | |
attr_accessor :cells | |
def initialize | |
@cells = [] | |
end | |
def push_cell cell | |
@cells = @cells << cell | |
end |
This file contains 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 Discussion < ActiveRecord::Base | |
scope :with_includes, -> { includes(:comments, :category) } | |
scope :by_recency, -> { order('created_at DESC') } | |
scope :visible, -> { where(hidden: false) } | |
end |
This file contains 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
# We create a new class with some sane defaults | |
class Garden | |
def initialize(args={}) | |
@trees = args[:trees] || 15 | |
@perimiter = args[:perimiter] || 'fence' | |
@lawn = args[:lawn] || 'grass' | |
end | |
end |
This file contains 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
# Find your tour ID | |
tour = Tour.find(xxx) | |
Cache::Tour.new(tour).delete | |
# This clears memcache for all regions |
This file contains 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 ErrorsController < ApplicationController | |
def not_found | |
# Will render the app/views/errors/not_found.html.erb template | |
def not_found | |
respond_to do |format| | |
format.html { render template: 'errors/not_found', layout: 'layouts/application', status: 404 } | |
# Below is to ensure rails doesn't 500 when someone requests /blahblahblah.js or any other non-html format. | |
format.all { render nothing: true, status: 404 } | |
end | |
end |
This file contains 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
capybara-2.2.1/lib/capybara/rails.rb:15:in `<top (required)>': undefined method `join' for nil:NilClass (NoMethodError) |
This file contains 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
INFO [5cab5ea4] Running ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiqctl stop /home/deploy/myapp/shared/tmp/pids/sidekiq.pid 10 on 255.255.255.255 | |
DEBUG [5cab5ea4] Command: cd /home/deploy/myapp/current && ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiqctl stop /home/deploy/myapp/shared/tmp/pids/sidekiq.pid 10 | |
DEBUG [5cab5ea4] Sidekiq shut down gracefully. | |
INFO [edd9b953] Running ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiq --index 0 --pidfile /home/deploy/myapp/shared/tmp/pids/sidekiq.pid --environment production --logfile /home/deploy/myapp/shared/log/sidekiq.log --daemon on 255.255.255.255 | |
DEBUG [edd9b953] Command: cd /home/deploy/myapp/current && ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiq --index 0 --pidfile /home/deploy/myapp/shared/tmp/pids/sidekiq.pid --environment production --logfile /home/deploy/myapp/shared/log/sidekiq.log --daemon | |
INFO [edd9b953] Finished in 1.817 seconds with exit status 0 (successful). | |
INFO [c1681dc0] Running ~/.rvm/bin/rvm 2.1.1 do bundle exec sidekiq --index 0 --pidfile /home |
This file contains 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
Given the following domain and scenario: | |
Topic has_many votes | |
A rails noob that has a massive dataset but little understanding into ActiveRecord query methods | |
and little SQL knowledge. | |
Using elegant and idiomatic Ruby, what is a good solution for returning all topics sorted by the | |
number of votes they have. Because of the SQL knowledge gap, you should avoid having to use SQL directly. |
NewerOlder