http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
- 複雜的 action
- action 裡面牽涉到多個 model ( 如 e-commerce 的結帳,牽扯到訂單, 使用者, 明細的修改 )
- action 裡面牽扯到外部 service ( 例如 po 到 twitter 上)
- action 的不是這個 model 核心業務的一部分(如清除舊資料...)
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y upgrade | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
curl -L https://get.rvm.io | bash | |
source /etc/profile.d/rvm.sh | |
rvm requirements | |
rvm install 2.0.0 | |
source /etc/profile.d/rvm.sh | |
gem install chef ruby-shadow --no-ri --no-rdoc |
<% [:notice, :error, :alert].each do |level| %> | |
<% unless flash[level].blank? %> | |
<div class="alert-message <%= flash_class(level) %>"> | |
<a class="close" href="#">×</a> | |
<%= content_tag :p, flash[level] %> | |
</div> | |
<% end %> | |
<% end %> |
#!/usr/bin/env perl | |
use constant MoeDatabase => "$ENV{HOME}/w/newdict/development.sqlite3"; | |
for my $arg (@ARGV) { | |
my $col = 'title'; | |
if ($arg =~ /%$/) { | |
$arg = "%$arg"; | |
$col = 'def'; | |
} | |
$arg .= '%' unless $arg =~ s/\$$//; | |
system sqlite3 => MoeDatabase, qq[ |
require 'spec_helper' | |
describe FeaturePool do | |
it "creates a new instance given valid attributes" do | |
Fabricate :feature_pool | |
end | |
it "is not valid without a name" do | |
Fabricate.build(:feature_pool, :name => "").should_not be_valid | |
end |
# | |
# Jekyll Generator for SCSS | |
# | |
# (File paths in this description relative to jekyll project root directory) | |
# Place this file in ./_plugins | |
# Place .scss files in ./_scss | |
# Compiles .scss files in ./_scss to .css files in whatever directory you indicated in your config | |
# Config file placed in ./_sass/config.rb | |
# |
$(function() { | |
var converter = new Showdown.converter(); | |
$("#user_input").keyup(function(){ | |
var txt = $("#user_input").val(); | |
var html = converter.makeHtml(txt); | |
$("#result").html(html) | |
$("#html_result").val(html.replace(/>/g, ">\n").replace(/</g, "\n<").replace(/\n{2,}/g, "\n\n")); | |
}); | |
var sample = "#### Underscores\nthis should have _emphasis_\nthis_should_not\n_nor_should_this\n\n\ |
#!/usr/bin/ruby | |
# README | |
# gem install aws-sdk | |
# add this to bashrc | |
# export HT_DEV_AWS_ACCESS_KEY_ID=???? | |
# export HT_DEV_AWS_SECRET_ACCESS_KEY=???? | |
# put your pem file in ~/.ssh and chmod 0400 | |
# for more info see; https://rubygems.org/gems/aws-sdk |
sudo: required | |
script: | |
- sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc | |
- gcc --version | |
addons: | |
apt: | |
sources: | |
- ubuntu-toolchain-r-test | |
packages: | |
- gcc-5 |
// | |
// KeyboardViewController.swift | |
// Demo Custom Keyboard | |
// | |
// Created by Drew Lustro on 10/20/14. | |
// | |
// Original derived from tutorial found on AppDesignVault | |
// http://www.appdesignvault.com/ios-8-custom-keyboard-extension/ | |
// | |
// |