<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'Validating image URL' | Pragmatic Forums</title>
    <link>http://forums.pragprog.com/forums/66/topics/396</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>Validating image URL posted by Chris Bloom @ Thu, 31 Jul 2008 04:19:47 -0000</title>
      <description>&lt;p&gt;Huh, I was getting an error about an kINTEGER instead of a kEND until I came here and found out that it is supposed to be an &amp;#8220;i&amp;#8221; at the end of the regexp. I swear it looks like a &amp;#8220;1&amp;#8221; when viewing the &lt;span class="caps"&gt;PDF&lt;/span&gt; at 67%&lt;/p&gt;</description>
      <pubDate>Thu, 31 Jul 2008 04:19:47 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:396:3853</guid>
      <author>Chris Bloom</author>
      <link>http://forums.pragprog.com/forums/66/topics/396</link>
    </item>
    <item>
      <title>Validating image URL posted by Bruce C. Martin III @ Wed, 30 Apr 2008 17:49:22 -0000</title>
      <description>&lt;p&gt;That&amp;#8217;s it for some reason my mind looked right over the comma. It&amp;#8217;s in the text plain as day. Thanks.&lt;/p&gt;


	&lt;p&gt;Bruce&lt;/p&gt;</description>
      <pubDate>Wed, 30 Apr 2008 17:49:22 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:396:2692</guid>
      <author>Bruce C. Martin III</author>
      <link>http://forums.pragprog.com/forums/66/topics/396</link>
    </item>
    <item>
      <title>Validating image URL posted by Sam Ruby @ Tue, 29 Apr 2008 20:17:35 -0000</title>
      <description>&lt;p&gt;There needs to be a comma (&amp;#8221;,&amp;#8221;) at the end of the line that reads &amp;#8220;validates_format_of :image_url,&amp;#8221;.  Without that comma, Ruby thinks that the statement is complete, and gets confused when it attempts to process the next line.&lt;/p&gt;</description>
      <pubDate>Tue, 29 Apr 2008 20:17:35 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:396:2678</guid>
      <author>Sam Ruby</author>
      <link>http://forums.pragprog.com/forums/66/topics/396</link>
    </item>
    <item>
      <title>Validating image URL posted by Bruce C. Martin III @ Tue, 29 Apr 2008 19:32:59 -0000</title>
      <description>&lt;p&gt;I have just started working with &lt;span class="caps"&gt;AWDR&lt;/span&gt; and have the beta of the third edition. I have run into a problem when trying to validate the image url. Here is what I have in the product.rb file, excluding the begining and ending quotes.&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class Product &amp;lt; ActiveRecord::Base 
  validates_presence_of :title, :description, :image_url
  validates_numericality_of :price
  validate :price_must_be_at_least_a_cent
  validates_uniqueness_of :title
  validates_format_of :image_url
                      :with =&amp;gt; %r{.(gif|jpg|png)$}i,
                      :message =&amp;gt; "must be a URL for GIF, JPG or PNG image.(gif/jpg/png)" 

protected
  def price_must_be_at_least_a_cent
    errors.add(:price, 'should be at least 0.01')if price.nil? || price &amp;lt; 0.01    
  end
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;but I end up with the follow error when I refresh the page.&lt;/p&gt;


	&lt;p&gt;C:/Ruby_Test/depot/app/models/product.rb:7: syntax error, unexpected tASSOC, expecting kEND
                      :with =&amp;gt; %r{.(gif|jpg|png)$}i,
                              ^&lt;br /&gt;C:/Ruby_Test/depot/app/models/product.rb:7: syntax error, unexpected &amp;#8217;,&amp;#8217;, expecting kEND&lt;/p&gt;


	&lt;p&gt;did I miss something in the book?&lt;/p&gt;


	&lt;p&gt;Bruce&lt;/p&gt;</description>
      <pubDate>Tue, 29 Apr 2008 19:32:59 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:66:396:2676</guid>
      <author>Bruce C. Martin III</author>
      <link>http://forums.pragprog.com/forums/66/topics/396</link>
    </item>
  </channel>
</rss>
