2010-11-29 38 views

回答

2

這是相當簡單:

# products_controller.rb 
before_filter :authenticate 

protected 

def authenticate 
    authenticate_or_request_with_http_basic do |username, password| 
    username == "foo" && password == "bar" 
    end 
end 

參見:http://railscasts.com/episodes/82-http-basic-authentication

+0

涵蓋認證部分= \謝謝!現在只需要子域。 = \ – NullVoxPopuli 2010-11-29 15:14:19

1

寫小架的應用。這兩個檢查是否正確的子域和強制執行基本身份驗證可以輕鬆完成。

+0

本着railscasts的精神,這個http://railscasts.com/episodes/221-subdomains-in-rails-3會告訴你關於子域名的一切。 – 2010-11-29 15:15:41