Undefined method errors when I try to use a column alias for an aggregate (PostgreSQL)
Inside my model:
class B2bLoginAttempt < ActiveRecord::Base
set_table_name "b2b_logins"
end
Inside my controller:
@client_ip = request.env['REMOTE_ADDR']
@sql = "select count(id) as failed_logins FROM b2b_logins WHERE ip_address = '"+@client_ip+"'"
f = B2bLoginAttempt.find_by_sql(@sql)
failed_attempts = f.failed_logins.to_s
f.destroy
Then I see: undefined method `failed_logins' for #<Array:0x104d08478>