Syntax error when rescuing ActiveRecord::RecordNotUnique errors for users

Description

We have the following code in the users_controller that we use when rescuing Record Not Unique errors:

User.count(conditions: { login: @user.login }) > 0

However, that produces an error:

ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':conditions=>{:login=>"testy"}}) FROM `users`' at line 1: SELECT COUNT({:conditions=>{:login=>"testy"}}) FROM `users`

We should replace it with code that doesn't error.

This can't really be tested manually.

Environment

None

Status

Assignee

Unassigned

Reporter

Sarken

Roadmap

Users

Priority

Medium

Affects versions

Fix versions

None

Components

BackEnd

Difficulty

Easy

Required Access Level

None

Milestone

Internal 0.9
Configure