Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User has created an account with a blank address field #35

Open
crowbot opened this issue Apr 18, 2017 · 4 comments
Open

User has created an account with a blank address field #35

crowbot opened this issue Apr 18, 2017 · 4 comments

Comments

@crowbot
Copy link
Member

crowbot commented Apr 18, 2017

This is causing validation errors when they try to confirm their account:

An ActiveRecord::RecordInvalid occurred in user#confirm:

Validace je neúspešná: Address Musíte vložit adresu.
activerecord (3.2.22.3) lib/active_record/validations.rb:56:in `save!'

Actually looks like this is an older account, so they've somehow been able to delete the address information.

@garethrees
Copy link
Member

I was just looking at this.

ID	622
Created at	2016-04-07 09:29:06 +0200
Updated at	2017-04-18 02:09:25 +0200

Looks like they're following a PostRedirect (created yesterday).

@crowbot
Copy link
Member Author

crowbot commented Apr 18, 2017

OK, I'll let you dig into it.

@garethrees
Copy link
Member

I think this is what's happening:

@garethrees
Copy link
Member

garethrees commented Apr 18, 2017

IMO, the above code flow is a bit broken. We shouldn't be updating the record when a user just wants to follow a "log me in to do X" URL.

As a quick fix, I've just updated all users without an address:

User.where(:address => nil).update_all(:address => '-')
#  SQL (4.1ms)  UPDATE "users" SET "address" = '-' WHERE "users"."address" IS NULL
#=> 6
User.where(:address => nil).count
#   (1.4ms)  SELECT COUNT(*) FROM "users" WHERE "users"."address" IS NULL
#=> 0
User.where(:address => '').update_all(:address => '-')
#  SQL (224.0ms)  UPDATE "users" SET "address" = '-' WHERE "users"."address" = ''
#=> 81
User.where(:address => '').count
#   (1.5ms)  SELECT COUNT(*) FROM "users" WHERE "users"."address" = ''
#=> 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants