Rails - block everything except a specific IP address

I am working on a rails 3 application that I would like to temporarily block with all requests not coming from my IP address. What is the best way to do this?

I decided that I could do something at the controller level, but I was new and not sure what the best practice was.

+6
ruby-on-rails
source share
1 answer

Wrap all your routes in a constraints block:

 constraints :ip => "your-ip-goes-here" do # routes go here end 

Your Rails application will lose all routing knowledge if other people try to access it.

This method is very convenient if you want to restrain other things, for example, an example of an iPhone that shows documentation.

+9
source share

All Articles