开发者

Rails 3. Cannot validate URLs for http prefix

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜