With Rails 3 routes, how do you only allow a requests from 127.0.0.1?
Posted
by micah
on Stack Overflow
See other posts from Stack Overflow
or by micah
Published on 2010-06-16T00:29:49Z
Indexed on
2010/06/16
0:32 UTC
Read the original article
Hit count: 233
routes
|ruby-on-rails3
I'm writing an app where several of the routes should only be accessible from localhost. It looks like this is possible with the new routing system.
http://www.railsdispatch.com/posts/rails-3-makes-life-better
This has examples of restricting routes based on IP address, and setting up an IP address blacklist for your routes, but I'm interested in a whitelist with just one IP address.
It would be cool if something like this worked:
get "/posts" => "posts#show", :constraints => {:ip => '127.0.0.1'}
But it didn't. Am I just missing the right syntax?
© Stack Overflow or respective owner