Is there an easy way how to validate urls in Rails 4 without using a Gem?
I found the validate_url gem already but i dont actually want to use it, as I think there needs to be a built-in way of doing that
Is there an easy way how to validate urls in Rails 4 without using a Gem?
I found the validate_url gem already but i dont actually want to use it, as I think there needs to be a built-in way of doing that
I found a good way to do validate an url in rails 4 with a method of the URI class.
class User < ActiveRecord::Base
validates_format_of :url, :with => URI::regexp(%w(http https))
end
In addition to @Mik's answer, I also use the browser HTML form:
<%= f.url_field :url %>