Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
;; emacs configuration | |
(push "/usr/local/bin" exec-path) | |
(add-to-list 'load-path "~/.emacs.d") | |
(setq make-backup-files nil) | |
(setq auto-save-default nil) | |
(setq-default tab-width 2) | |
(setq-default indent-tabs-mode nil) | |
(setq inhibit-startup-message t) |
#include <boost/filesystem.hpp> | |
#include "SystemHelpers.h" | |
using namespace boost::filesystem; | |
/// ... | |
void getLoggingMethods( FB::Log::LogMethodList& outMethods ) | |
{ | |
path appDataPath = FB::System::getLocalAppDataPath("CompanyName"); |
build_package_stdout_patch() { | |
wget 'http://bugs.ruby-lang.org/attachments/download/1931/stdout-rouge-fix.patch' | |
patch -p1 < stdout-rouge-fix.patch | |
} | |
require_gcc | |
install_package "ruby-1.8.7-p358" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p358.tar.gz" stdout_patch standard | |
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz" ruby | |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>App Redirection</title> | |
</head> | |
<body> | |
<!-- | |
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom | |
protocol handlers. |
We need to patch Go's source code to allow cgo when cross-compiling and make Android-specific changes since it sometimes differs from linux (e.g.: it doesn't use /etc/resolv.conf for DNS config)
hg clone -u release https://code.google.com/p/go
cd go
patch -p1 < /path/to/patch/go_android.patch
cd src