02 Apr 2014, 05:51
Generic-user-small

Michael Stromberg (1 post)

When trying to implement the format validation of :image_url I get the following error screen when trying to view my changes using the rails server command:

The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option?

Here is my product.rb file:

class Product < ActiveRecord::Base validates :title, :description, :image_url, :presence => true validates :price, :numericality => {:greater_than_or_equal_to => 0.01} validates :title, :uniqueness => true validates :image_url, :format => { :with => %r{.(gif|jpg|png)$}i, :message => ‘must be a URL for GIF, JPG or PNG image.’ } end

I’m not sure what I am doing wrong here. Any help would greatly be appreciated.

Thanks.

03 Apr 2014, 13:21
Generic-user-small

Stefan Maier (1 post)

Hey I had this problem too.

solved it =>

validates :image_url, :format => { :with => %r{.(gif|jpg|png)\Z}i, :message => ‘must be a URL for GIF, JPG or PNG image.’ }

best Stefan

  You must be logged in to comment