I have a little problem:
I have this in my model:
validates :title, :presence => true, :uniqueness => true, :format => /[A-Z][A-Za-z0-9\-_]*/i
This in my controller:
def create
@page = Page.new params[:page]
if verify_recaptcha(:model => @page) && @page.save
redirect_to @page
else
render :action => :new
end
end
However, someone created a page with a + in its title. How can this happen? Is the RegEx wrong? I can’t find the problem.
Try putting start and end matchers in your regex:
Otherwise it still matches if the + is at the start or end.