Skip to content

Instantly share code, notes, and snippets.

@BlueVajra
Created April 30, 2014 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueVajra/2a6c7dd58162c5e13d59 to your computer and use it in GitHub Desktop.
Save BlueVajra/2a6c7dd58162c5e13d59 to your computer and use it in GitHub Desktop.
Rails Examples
class Url < ActiveRecord::Base
validates :url, presence: {message: "URL can not be blank"}
validates :url, format: {
with: /(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?/ix,
message: "The text you entered is not a valid URL"
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment