0

例如,尝试保存图像 url

http://ecx.images-amazon.com/images/I/51d2Qu4RGFL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg

我的迁移:

t.string   "promo_url"

我的表格:

<i class="icon-link"></i><%= f.text_field :promo_url, autocomplete: "off", placeholder: "Image URL" %>

在 Event#Create 上莫名其妙地无声地挂起:

@event.save

痕迹:

Request
User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 12 ORDER BY name LIMIT 1
Event Load (0.4ms)  SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1  [["id", "64"]]
(0.1ms)  BEGIN

感谢您的帮助——我以前从未见过 Rails 服务器像这样挂起。

4

1 回答 1

0

我的 url 验证对于域 url 是准确的,但不是图像 url。

@url = /^((https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?)?$/ 
validates :link, :promo_url :format => { :with => @url }, allow_blank:true
于 2012-11-06T19:40:47.973 回答