There is no excuse for not following these
- It solves the problem.
- It doesn't break Demeter.
- It follows single responsibility.
- Naming is declarative.
require 'simplecov' | |
SimpleCov.start 'rails' do | |
add_filter 'app/controllers/[\w_]*.rb' | |
add_filter 'app/models/[\w_]*.rb' | |
add_filter 'app/modules/[\w_]*.rb' | |
end | |
SimpleCov.minimum_coverage 100 |
module Api::V1 | |
class foo | |
include ActiveModel::Serializers::JSON | |
def create(attrs) | |
end | |
def find(id) | |
class ApiConstraints | |
def initialize(options) | |
@version = options[:version] | |
@default = options[:default] | |
end | |
def matches?(req) | |
@default || req.headers['Accept'].include?("application/vnd.betterbills.v#{@version}") | |
end | |
end |
crontab -l | { cat; echo "@hourly 'for i in {1..20}; do say wub; done'"; } | crontab - |
source "https://rubygems.org" | |
# Declare your gem's dependencies in service_qualification.gemspec. | |
# Bundler will treat runtime dependencies like base dependencies, and | |
# development dependencies will be added by default to the :development group. | |
gemspec | |
# Declare any dependencies that are still in development here instead of in | |
# your gemspec. These might include edge Rails or gems from your path or | |
# Git. Remember to move these dependencies to your gemspec before releasing |
# Indexes | |
Bike.where(style: 'FIXIE').explain['indexBounds'] | |
Bike.where(brand_name: 'Genesis').explain['indexBounds'] | |
Bike.where(style: 'FIXIE', brand_name: 'Genesis').explain['indexBounds'] | |
# Nil and unset | |
chinarello = Bike.first | |
chinarello.colour = nil | |
chinarello.save | |
chinarello.reload |
class Bike | |
include Mongoid::Document | |
field :brand_name | |
validates :brand_name, presence: true | |
STYLES = %w(CARBON_MONSTROSITY DUALIE FIXIE TOURER) | |
field :style | |
validates :style, inclusion: STYLES |
class Bike | |
include Mongoid::Document | |
field :brand_name | |
validates :brand_name, presence: true | |
STYLES = %w(CARBON_MONSTROSITY DUALIE FIXIE TOURER) | |
field :style | |
validates :style, inclusion: STYLES |
def alert_log | |
AlertLog.find(:all, :joins => [:want, :alert], | |
:conditions => ['wants.user_id = ? OR alerts.user_id = ?', id, id]) | |
end |