Skip to content

Commit

Permalink
Done.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronchu357 committed May 22, 2019
1 parent 5c29201 commit 0c84882
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/author.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class Author < ActiveRecord::Base
validates :name, presence: true
validates :name, uniqueness: true
validates :phone_number, length: {is: 10}
end
12 changes: 12 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
class Post < ActiveRecord::Base
validates :title, presence: true
validates :content, length: {minimum: 250}
validates :summary, length: {maximum: 250}
validates :category, inclusion: {in: %w(Fiction Non-Fiction)}
validate :clickbait

def clickbait
arr = [ /Won't Believe/i, /Secret/i, /Top [0-9]*/i, /Guess/ ]
if arr.none? {|bait| bait.match title}
errors.add(:title, "not clickbait-y enough!")
end
end
end

0 comments on commit 0c84882

Please sign in to comment.