Skip to content
Advertisement

Tag: ruby-on-rails

Get users with no postings or no active postings

I have a rails schema and I have users table and postings table. I am trying to get all users that either have no postings or no active postings. Active being a column on postings that can be true or false. Is the following correct? The thing is, if the user has any postings that are active: true, I DO

How to sanitize Arel SQL?

I have the following Arel SQL: I get SQL Injection warning when I run brakeman. I tried the following: However, I get the following error: How do I sanitize sql statement with Arel? Answer I am answering my own question. I am using Arel following the Github wiki for Ransack gem. I was doing something very similar to point #

speed up the query which is taking 2 seconds on 1000000 on active records also on PostgreSQL Sql

I’m creating a dynamic query on the server side beside the parameter. However, my query is taking 2 seconds to fetch the records. I’m passing the query through active records let me share the query and Active record rails code SELECT (custom_attribute_values.attributable_id) FROM custom_attribute_values WHERE ((“custom_attribute_id” = ’12’ AND “value_string” = ‘Female’) OR (“custom_attribute_id” = ’12’ AND “value_string” = ‘Male’))

Advertisement