Devise inet fields may be treated as Field::String in Administrate, which results in SQL errors when searching
Created by: maxkwallace
I'm seeing an ActiveRecord::StatementInvalid
error when searching over my Users in Administrate.
Postgres gives the following error:
PG::UndefinedFunction: ERROR: function lower(inet) does not exist
The SQL query that's erroring looks like:
SELECT "users".* FROM "users" WHERE (lower(email) LIKE '%george%' OR lower(current_sign_in_ip) LIKE '%george%' ... ) LIMIT 20 OFFSET 0
As far as I can tell, this is because the current_sign_in_ip
attribute (managed by Devise) is treated as a String in Administrate:
current_sign_in_ip: Field::String,
whereas it's actually an inet in Postgres:
t.inet "current_sign_in_ip"
so attempting to use lower
on it fails.
This isn't an urgent issue-- simply deleting the offending attributes from ATTRIBUTE_TYPES
in my user_dashboard.rb
file allows me to search just fine. The only downside is that I can't see the current_sign_in_ip
attribute in Administrate, which really doesn't matter. But I thought it was worth reporting.