Source code :

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

 

This %r{.(gif|jpg|png)$}i,cause the error. In order to fix it, remember While A and z are Permanent Start of String and End of String anchors. Change the code like this :

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{A.(gif|jpg|png)/z}i,
:message => ‘must be a URL for GIF, JPG or PNG image.’
}
end