Generic-user-small Martin Hawkins 1 post

v2, p85:
validates_format_of :image_url,
:with => %r{\.(gif|jpg|png)$}i,
:message => “must be a URL for a GIF, JPG, or PNG image”

What does the “i” do at the end of the second line? I’ve tried it without and it seems to run fine.

 
Samr_small_small Sam Ruby 109 posts

It makes the regular expression case insensitive. With the i specified, the regular expression will match gif, GIF, Gif, gIf, etc.

2 posts, 2 voices