constraints :remote_ip => "127.0.0.1" do
      get '/restricted' => "root#restricted"
  end

“You can also constrain a route based on any method on the Request object that returns a String.”

http://guides.rubyonrails.org/routing.html#request-based-constraints