From fcd0ef5edec94c99b7eacc35c669b788f0c8a973 Mon Sep 17 00:00:00 2001 From: Joseph Zang Date: Thu, 7 Nov 2013 15:21:50 -0600 Subject: [PATCH] parameter validation for title, text_top, and text_bottom in app/models/captioned_image.rb --- app/models/captioned_image.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/captioned_image.rb b/app/models/captioned_image.rb index 5b9f77e..ecfb950 100644 --- a/app/models/captioned_image.rb +++ b/app/models/captioned_image.rb @@ -2,6 +2,10 @@ class CaptionedImage < ActiveRecord::Base attr_accessible :source_image_id, :text_bottom, :text_top, :title belongs_to :source_image delegate :adoption_info_url, to: :source_image + validates :title, :text_top, :text_bottom, allow_blank: true, format: { + with: %r{\A[A-Za-z0-9 _-?!]\Z}, + message: 'Only letters, numbers, underscores, hyphens, question marks, and exclamation marks are allowed.' + } def image_url SimpleMemeCaptainClient.captioned_image_url(u: source_image.url,