Rails - Block all but certain IP address
I'm working on a rails 3 app that I would like to tem开发者_如何转开发porarily be blocked by all requests not coming from my IP address. What is the best way to go about that?
I figured I could do something at the controller level, but I'm a newb and was not sure what the best practice is.
Wrap all your routes in a constraints
block:
constraints :ip => "your-ip-goes-here" do
# routes go here
end
Your Rails app will deny all knowledge of routing if other people try to access this.
This method is really handy if you want to constrain based on other things too, like the iPhone example the documentation shows.
精彩评论