#793 open
Betelgeuse

User validates email_address twice if it's marked unique

Reported by Betelgeuse | September 15th, 2010 @ 01:15 PM | in Hobo 1.4

>> u = InheritedUser.new :name => 'User', :email_address => 'email@foo.com'
=> #<InheritedUser id: nil, crypted_password: nil, salt: nil, remember_token: nil, remember_token_expires_at: nil, name: "User", email_address: "email@foo.com", administrator: false, created_at: nil, updated_at: nil, state: "active", key_timestamp: nil, type: "InheritedUser", extra: nil>
>> u.valid?
=> false
>> u.errors.full_messages
=> ["Name has already been taken", "Email address has already been taken", "Email address has already been taken"]
betelgeuse@mac ~/sti_problems $ head  app/models/user.rb 
class User < ActiveRecord::Base

  hobo_user_model # Don't put anything above this

  fields do
    name          :string, :required, :unique
    email_address :email_address, :unique, :login => true
    administrator :boolean, :default => false
    timestamps
  end

Comments and changes to this ticket

  • Matt Jones

    Matt Jones September 14th, 2011 @ 08:44 PM

    • State changed from “new” to “open”
    • Assigned user set to “Matt Jones”
    • Milestone set to Hobo 1.4
    • Title changed from “Inheriting User with STI validates email_address twice if it's marked unique” to “User validates email_address twice if it's marked unique”
    • Milestone order changed from “197885” to “0”

    I've fixed the title on this - I got the same behavior with a plain User model in 1.3.0.RC2. The issue appears to be that setting login_attribute adds a uniqueness validation (case-insensitive) while passing :unique adds one as well.

    This may require a bit more discussion - I'm thinking that login_attribute= might be more useful if it added an index as well, since it's essentially guaranteed that the application need one.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Pages