class Question < ActiveRecord::Base

  belongs_to :user
  has_many :responses, dependent: :destroy

  validates :image_path, presence: true
  validates_format_of :image_path, :with => URI::regexp(%w(http https))

  before_save :create_slug

  def create_slug
    self.slug = self.title.parameterize
  end

end

class Question < ActiveRecord::Base

  belongs_to :user
  has_many :responses, dependent: :destroy

  validates :image_path, uniqueness: { scope: :user}, presence: true
  validates_format_of :image_path, :with => URI::regexp(%w(http https))

  before_save :create_slug

  def create_slug
    self.slug = self.title.parameterize
  end

end

Validate To Ensure User Doesn't Add Same Photo
Validate To Ensure User Doesn't Add Same Photo
