docbrown/app/models/search_keyword.rb
Ben Halpern 75d3a79c12
Add search_keywords record and associated functionality (#494)
* Add search_keywords record and associated functionality

* Fix test and add badge rewarder method
2018-06-25 11:58:07 -04:00

17 lines
552 B
Ruby

class SearchKeyword < ApplicationRecord
validates :keyword, presence: true
validates :google_result_path, presence: true
validates :google_position, presence: true
validates :google_volume, presence: true
validates :google_difficulty, presence: true
validates :google_checked_at, presence: true
validate :path_format
private
def path_format
unless google_result_path&.starts_with?("/") && google_result_path&.count("/") == 2
errors.add(:google_result_path, "must start with / and be properly formatted")
end
end
end