开发者

Rails 3. Cannot validate URLs for http prefix

开发者 https://www.devze.com 2023-01-27 02:07 出处:网络
I am developing an application in Rails 3 and in this application I let the users add URLs to websites. The current problem I am facing is that some of the users forget to include the http or https pr

I am developing an application in Rails 3 and in this application I let the users add URLs to websites. The current problem I am facing is that some of the users forget to include the http or https prefixes which results in a non working link.

Unfortunately there seems to be no way to validate this out of the box? H开发者_运维知识库ow can I go about to validate if the submitted URL includes http?

Thankful for all help!


There is a plugin named validates_url_format_of that seems to work for Rails 3. Otherwise you can write your own custom validator.

0

精彩评论

暂无评论...
验证码 换一张
取 消