Skip to content

Instantly share code, notes, and snippets.

@kenmazaika
Created January 14, 2016 18:20
Show Gist options
  • Save kenmazaika/1c065bb1299424343781 to your computer and use it in GitHub Desktop.
Save kenmazaika/1c065bb1299424343781 to your computer and use it in GitHub Desktop.
class Quote < ActiveRecord::Base
validates :saying, presence: true, length: { maximum: 140, minimum: 3 }
validates :author, presence: true, length: { maximum: 50, minimum: 3 }
before_create :remove_leading_and_trailing_quotes
def remove_leading_and_trailing_quotes
self.saying = self.saying.gsub(/\A"/, '').gsub(/"\Z/, '')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment