Module: Pulitzer::PostsController::Validations

Included in:
Create, Update
Defined in:
app/interactions/pulitzer/posts_controller/validations.rb

Instance Method Summary collapse

Instance Method Details

#validate_titleObject



2
3
4
5
6
7
8
9
# File 'app/interactions/pulitzer/posts_controller/validations.rb', line 2

def validate_title
  if Pulitzer::Post.where(title: @post.title).to_a.any?{|post|
    (post.post_type_version_id == @post.post_type_version_id)}
    @post.errors.add(:title, 'Another post already has this title')
    return false
  end
  return true
end