Skip to content

Instantly share code, notes, and snippets.

@codebeige
codebeige / friendship.rb
Last active December 6, 2016 12:19
Friendship queries
class Friendship < ActiveRecord::Base
belongs_to :requester, class_name: 'User'
belongs_to :accepter, class_name: 'User'
scope :pending_and_confirmed, -> { unscope(where: :accepted_at) }
scope :confirmed, -> { unscope(where: :accepted_at).where.not(accepted_at: nil) }
scope :pending, -> { unscope(where: :accepted_at).where(accepted_at: nil) }
scope :by_user, ->(user) { where('requester_id = :user_id OR accepter_id = :user_id', user_id: user) }

Keybase proof

I hereby claim:

  • I am codebeige on github.
  • I am codebeige (https://keybase.io/codebeige) on keybase.
  • I have a public key whose fingerprint is C5EA C03B 1066 9784 7E8C 122C 557D 10DC 829F 3EFD

To claim this, I am signing this object:

@codebeige
codebeige / rails_helper.rb
Created April 17, 2016 15:50
Assign locals context-wide when testing partials with rspec-rails
RSpec.configure do |config|
config.include TemplateLocals, type: :view
end
@codebeige
codebeige / gist:7039546
Created October 18, 2013 10:23
Install Ruby with Homebrew OpenSSL
CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --with-readline-dir=$(brew --prefix readline)" rbenv install 2.0.0-p247
@codebeige
codebeige / gist:6448261
Created September 5, 2013 10:05
Install Ruby Enterprise Edition on OSX 10.8
CONFIGURE_OPTS="-c --enable-shared -c --with-readline-dir=$(brew --prefix readline)" rbenv install ree-1.8.7-2012.02