class Notebook < ActiveRecord::Base
  belongs_to :user

  validates :name, presence: true
  validates :name, uniqueness: { scope: :user_id }
end

class Notebook < ActiveRecord::Base
  belongs_to :user

  validates :name, presence: true
  validates :name, uniqueness: { scope: :user }
end

Use association as a uniqueness scope not the actual column name
Use association as a uniqueness scope not the actual column name
