2012-06-05 72 views

回答

3
class SignupsController < ApplicationController 
    before_filter :block_ip_addresses 

    protected 

    def block_ip_addresses 
    head :unauthorized if current_ip_address == "XX.XX.XX.XX" 
    end 

    def current_ip_address 
    request.env['HTTP_X_REAL_IP'] || request.env['REMOTE_ADDR'] 
    end 
end