解读Rails - 处理异常

2014-11-05
阅读 5 分钟
5k
Rails通过让你使用rescue_from方法,让你在你的controller里边为常见的异常定义处理方法。举例来说吧,你可以在用户试图访问他们尚未付费的功能时将他们重定向到指定的付费页面。

解读Rails - 适配器模式

2014-11-05
阅读 7 分钟
3.6k
今天我们暂时先放下具体的代码片段,我们将要对Rails中所实现的一个比较常见的设计模式进行一番探索,这个模式就是适配器模式(Adapter Pattern)。从一定的意义上来说,这次的探索并不全面,但是我希望能够突出一些实际的例子。

在Ruby中使用WebSocket

2014-11-05
阅读 3 分钟
6.7k
在我的主要工作中,需要构建一个一直占用相当大CPU时间片的数据系统。这个任务主要用于在地理编码以及local reference system(本地地理系统?)之间进行编码以及解码。举个例子,这个工作将帮助我们在系统中标记一条对应于街道上某个地点的记录,并且可以知道本地地理位置所对应的坐标。

DIY an Timer Through Terminal-notifier

2014-11-05
阅读 2 分钟
2.5k
Today I will show you how to DIY an intersting notifier automatically running per hour under the Mac OS X 10.8 and higher, all we need are a terminal-notifier and the system built-in command line program named crontab.

Split logs automatically every day

2014-11-05
阅读 3 分钟
4.5k
"linuxcommand: logrotate":[链接]42Xlogrotate is designed to ease administration of systems that generate large numbers of log files. Normally, logrotate is run as a daily cron job.

Backup Database and Other Attachments in ROR

2014-11-05
阅读 4 分钟
2.5k
Related Resources rsync:[链接] Crontab:[链接] "Linux Crontab 定时任务 命令详解":[链接] [rubygem]"backup":[链接] [rubygem]"whenever":[链接] Automatically backup on the remote server: Let's firstly assumpt: You have a site named "example.com"; You can login to it through a username "deploy", and it...

Write Css Codes Distinct From Different Pages

2014-11-05
阅读 1 分钟
1.9k
In rails, there is normally a view corresponding to an action. So if you want to do some special styles based on different pages, you can render controller name and action name in your layout file like this:

Failed to Stop or Restart Nginx Server Through Serevice Command

2014-11-05
阅读 2 分钟
3.4k
Many people are accustomed to start a Nginx web server through init scripts and then they can control the state of the server through service command, such as sudo service nginx restart. But sometimes unobvious config error makes the scripts failed to work. Here I will show an error related to pi...

Export/import Datas To/from a Csv File

2014-11-05
阅读 2 分钟
2.7k
今天需要给客户的网站做支持产品数据导出并且更新的功能,所以就涉及到了数据的导入导出了。在经过一番对比之下,果断使用csv格式文件作为数据导入导出的载体。

Rails HTTP Status Code to Symbol Mapping

2014-11-05
阅读 3 分钟
3k
Sometimes you might need to set the HTTP response head with different status to specify the different handled results. You can do this in Rails by add a :status to a rails method such as #respond_with. Here list all the maps:

Track Original Repo When Fork

2014-11-05
阅读 1 分钟
1.7k
{代码...}

Delete multiple git remote branches by prefixing colon

2014-11-05
阅读 1 分钟
1.8k
{代码...} Remember the colon :