This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Home
Validates that a URL is accessible and is an HTTP URL by opening a connection to the server.
class Company < ActiveRecord::Base
validates_http_url :homepage, :wrong_response => "did not return a successful HTTP code"
end
Configuration options:
valid_responses– An array of valid HTTP responses (as subclasses ofNet::HTTPResponse). By default this containsNet::HTTPSuccess(and therefore all subclasses of it, such asNet::HTTPOK). If you would like to add your own valid responses, make sure to includeNet::HTTPSuccessunless you explicitly want to remove it from the set of valid responses.wrong_response– A custom error message for when the server does not return a valid HTTP responsewrong_protocol– A custom error message for when the URL provided is not an HTTP URLmalformed_url– A custom error message for when a malformed URL is providedno_response– A custom error message for when there is no response from the address providedmessage– A custom error message to be used for any of the above error messages that are not specified
If you would like to specify a custom error message for a particular response code, pass a hash instead of a string for wrong_response. Map each Net::HTTPResponse subclass to the error message you’d like to use for that response. If you map an error message to Net::HTTPResponse, it will be used as the default error message for response codes without custom error messages. An example:
validates_http_url :url, :wrong_response => { Net::HTTPMovedPermanently => "has been moved", Net::HTTPResponse => "is not working correctly" }







