I want to validate an IP address before I login in my Admin Controller.
before_filter :validate_ip
How should I create this IP validation? I just want to write the IP addresses that have access in the controller.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first solution is dynamic, because you can populate the array in runtime:
The other way to restrict IPs is, to use constraints in your
routes.rb:For more information about Rails and Routes, be sure to check out: Rails Dispatch – The Powerful New Rails Router.