Module: Urlish::ModelAdditions

Defined in:
lib/urlish/model_additions.rb

Instance Method Summary collapse

Instance Method Details

#format_url(attribute) ⇒ Object



3
4
5
6
7
8
# File 'lib/urlish/model_additions.rb', line 3

def format_url(attribute)
  before_validation do
    send("#{attribute}=", Urlish.format_url(send(attribute)))
 end
 validates_format_of attribute, with: Urlish.url_regexp, message: "is not a valid URL"
end