This file contains hidden or 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 AccountsController < ApplicationController | |
include Authenticated | |
before_action :populate_default_attributes, only: %i(new) | |
expose :customer | |
expose :accounts, ancestor: :customer | |
expose :account | |
# def new omitted, thanks to DecentExposure... |
This file contains hidden or 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
# suffers the obvious problem that Time.now is evaluated at load, not on-call... | |
def prior_to(issue_date = Time.now) | |
where("issue_date < ?", issue_date).order(:issue_date).reverse_order | |
end |
This file contains hidden or 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
logger level: :warn | |
rspec_opts = { | |
zeus: true, | |
binstubs: true, | |
all_on_start: false, | |
cli: "--order rand:$RANDOM" | |
} | |
guard :rspec, rspec_opts do |
This file contains hidden or 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
# app/models/foo.rb | |
# Keep in mind, this doesn't even factor in TimeZones. | |
class Foo | |
# Including this line gives your model two virtual | |
# attributes - `date` and `time` - which you can use as | |
# methods in your form_for / f.text_field calls, etc | |
attr_writer :date, :time | |
# returns the date component of starts_at, to ensure |
This file contains hidden or 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
module HostnameHelper | |
def using_hostname(hostname) | |
old_host = Capybara.default_host | |
Capybara.default_host = "http://#{hostname}" | |
yield | |
Capybara.default_host = old_host | |
end | |
end |
This file contains hidden or 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
> gem install rails --version=4.0.0.beta1 --verbose | |
HEAD http://rubygems.org/prerelease_specs.4.8.gz | |
302 Moved Temporarily | |
HEAD http://production.s3.rubygems.org/prerelease_specs.4.8.gz | |
304 Not Modified | |
HEAD http://rubygems.org/specs.4.8.gz | |
302 Moved Temporarily | |
HEAD http://production.s3.rubygems.org/specs.4.8.gz | |
304 Not Modified | |
GET http://rubygems.org/quick/Marshal.4.8/rdoc-3.12.2.gemspec.rz |
This file contains hidden or 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
arr = [:a, :b, :c] | |
obj = :d | |
[*arr] # => [:a, :b, :c] | |
[*obj] # => [:d] |
This file contains hidden or 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
# Path to your oh-my-zsh configuration. | |
export ZSH=$HOME/.oh-my-zsh | |
# Set to the name theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
export ZSH_THEME="codeape" | |
# Set to this to use case-sensitive completion | |
# export CASE_SENSITIVE="true" |
This file contains hidden or 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
ZSH_THEME_GIT_PROMPT_PREFIX="" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="" | |
ZSH_THEME_GIT_PROMPT_CLEAN=" %F{46}±" | |
ZSH_THEME_GIT_PROMPT_DIRTY=" %F{196}±" | |
function codeape_prompt { | |
# set up the biggest possible middle padding we'd need | |
(( spare_width = ${COLUMNS} )) | |
prompt=" " |
This file contains hidden or 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
#!/usr/bin/env ruby -wKU | |
str = "Herp" | |
case str | |
when "Herp" | |
when "Derp" | |
puts "This will never, ever work the way you want it to. Ruby ain't PHP." | |
end |