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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With