Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
View GitHub Profile
@simlegate
simlegate / _service.md
Created January 16, 2016 11:54 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
zh-CN:
admin:
home:
name: "首页"
pagination:
previous: "« 上一页"
next: "下一页 »"
truncate: "…"
misc:
filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
<?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

# sudo ln -s ~/nginx.conf unicorn.conf
upstream app_server {
server unix:/tmp/unicorn_padrino.sock fail_timeout=0;
}
server {
listen 80;
charset utf-8;
server_name db.innshine.com;

💯 👍 👎 🔢 🎱 🅰️ 🆎 🔤 🔡 🉑 🚡 ✈️ ⏰ 👽 🚑 ⚓ 👼 💢 😠 😧 🐜 🍎 ♒ ♈ ◀️ ⏬ ⏫ ⬇️ 🔽 ▶️ ⤵️ ⤴️ ⬅️ ↙️ ↘️ ➡️ ↪️ ⬆️ ↕️ 🔼 ↖️ ↗️ 🔃 🔄 🎨 🚛 😲 👟 🏧 🅱️ 👶 🍼 🐤 🚼 🔙 🛄 🎈 ☑️ 🎍 🍌 ‼️ 🏦 📊 💈 ⚾ 🏀 🛀 🛁 🔋 🐻 🐝 🍺 🍻 🪲 🔰 🔔 🍱 🚴 🚲 👙 🐦 🎂 ⚫ 🃏 ⬛ ◾ :

Building Rich Domain Models in Rails.

Part 1. Decoupling Persistence.

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about in this article.