{"comment":{"created_at":"2011-10-08T07:32:39Z","body":"It seems that resolving issue [#143](https://github.com/norman/friendly_id/issues/143) introduced  `#exists?` in [485a19e](https://github.com/norman/friendly_id/commit/485a19e619c79fd590d22cfeaaf522c62b5b98bc). After removing `#exists?`, uniqueness validation works again in Rails 3.1.","updated_at":"2011-10-08T07:32:39Z","url":"https://api.github.com/repos/norman/friendly_id/issues/comments/2330907","id":2330907,"user":{"avatar_url":"https://secure.gravatar.com/avatar/7224339ef135349884c1e2a75f39133a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/znakaska","id":763058,"login":"znakaska"}},"action":"created","issue":{"number":152,"created_at":"2011-09-09T19:28:14Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"my scenario:\r\n\r\na rails app with a user model which uses friendly_id:\r\n\r\n\r\n```ruby\r\n# Gemfile:\r\n\r\ngem 'rails', '>=3.1.0'\r\ngem \"friendly_id\", :git => \"git://github.com/norman/friendly_id.git\"\r\n\r\n# app/models/user.rb:\r\n\r\nclass User < ActiveRecord::Base\r\n  attr_accessible :username, :email, :password, :password_confirmation\r\n  validates :email, :presence => true,\r\n                    :uniqueness => { :case_sensitive => false }\r\n\r\n  extend FriendlyId\r\n  friendly_id :username, :use => :slugged\r\nend\r\n\r\n# factories.rb:\r\n\r\nFactoryGirl.define do\r\n  factory :user do\r\n    factory :bob do\r\n      username \"Example User\"\r\n      email \"user@example.com\"\r\n      password \"foobar\"\r\n      password_confirmation \"foobar\"\r\n    end\r\n  end\r\nend\r\n\r\n# spec/models/user_spec.rb\r\n\r\nit \"should reject duplicate email addresses\" do\r\n  user = Factory(:bob)\r\n  Factory.build(:bob).should_not be_valid\r\nend\r\n```\r\n\r\nwithout the lines:\r\n\r\n```ruby\r\nextend FriendlyId\r\nfriendly_id :username, :use => :slugged\r\n```\r\nthe spec passes. So I figured it might have something to do with friendly_id.\r\n\r\nIn fact when I run this with friendly_id enabled\r\n\r\n```ruby\r\nUser.exists?(:email => 'marcel.scherf@epicteams.com')\r\n```\r\n\r\nI get the following error:\r\n\r\n``` ruby\r\nActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: slug.email: SELECT  1 FROM \"users\"  WHERE \"slug\".\"email\" = 'john.doe@example.com' LIMIT 1\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/sqlite3-1.3.4/lib/sqlite3/database.rb:91:in `initialize'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/sqlite3-1.3.4/lib/sqlite3/database.rb:91:in `new'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/sqlite3-1.3.4/lib/sqlite3/database.rb:91:in `prepare'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:175:in `block in exec_query'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:171:in `exec_query'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:382:in `select'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_one'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:30:in `select_value'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/relation/finder_methods.rb:197:in `exists?'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/bundler/gems/friendly_id-c03879ac0227/lib/friendly_id/finder_methods.rb:30:in `exists?'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/activerecord-3.1.0/lib/active_record/base.rb:441:in `exists?'\r\n        from (irb):1\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'\r\n        from /Users/work/.rvm/gems/ruby-1.9.2-p290@project/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'\r\n        from script/rails:6:in `require'\r\n        from script/rails:6:in `<main>'>>\r\n```\r\n\r\nIs this a known issue or is there an easy way around the problem?\r\n","comments":17,"title":"Breaks validates :uniqueness => true","updated_at":"2011-10-08T07:32:39Z","url":"https://api.github.com/repos/norman/friendly_id/issues/152","id":1610677,"assignee":{"avatar_url":"https://secure.gravatar.com/avatar/b6621ca717b64e2e1717b2af82e3762b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/norman","id":5042,"login":"norman"},"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/31510d2c98d186e9aef34ab879686774?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/the-architect","id":16360,"login":"the-architect"},"html_url":"https://github.com/norman/friendly_id/issues/152","labels":[],"state":"open"},"legacy":{"issue_id":1610677,"comment_id":2330907}}