Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
ssh -qTfnN -D 7070 user@remote-server |
# coding: utf-8 | |
class Translate | |
YOUDAO_HOST = "http://fanyi.youdao.com" | |
YOUDAO_QUERY_PATH = "openapi.do" | |
YOUDAO_KEY_FROM = "Paikeyun" | |
YOUDAO_KEY = "987423680" | |
def initialize(chars, opts = {}) | |
@chars = chars | |
@opts = opts |
require 'mini_magick' | |
class CustomAdmin::MiniCaptchaController < CustomAdmin::ApplicationController | |
before_filter :clear_captcha_session, :only => :mini_captcha | |
def self.get_responded_inquiry(mobile_no, company_id) | |
uncached do | |
self.find(:last, :conditions => ["mobile_no = ? and company_id = ? and response_status = 1", mobile_no, company_id]) | |
# self.find_all_by_mobile_no_and_company_id_and_response_status(mobile_no, company_id, 1).last | |
end | |
end | |
def self.last_req(mobile_no, company_id) | |
uncached do | |
self.find(:last, :conditions => ["mobile_no = ? and company_id = ?", mobile_no, company_id]) |
require 'socket' | |
require 'rubygems' | |
require 'eventmachine' | |
require 'logger' | |
require 'active_record' | |
# Rails -v: 2.3.5 | |
REF_RAILS_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','..')) | |
class MobileBalanceServer < EventMachine::Connection |
# coding: utf-8 | |
module SimpleUpload | |
class Base | |
class << self | |
def max_size | |
10485760 #(10M) | |
end | |
def extension_white_list |