0

The query which i have been trying to formulate is

select array_agg(is_online) , config->> 'external_host' from cameras group by config->> 'external_host';

this is running fine on PostgreSql query console, but not giving any response on Rails console not even error. is there any way to formulate that query in some way that it will be applicable for ActiveRecords?

1
  • same as i have pasted here, the same in console, bu the way @Abhi told me results are nill Commented Dec 17, 2015 at 6:46

2 Answers 2

1

Try find_by_sql.

Eg:-

ModelName.find_by_sql("sql_query;")

Reference DOC

If you are using rails version above 3.1.x then use a gem gem 'activerecord-deprecated_finders'

Sign up to request clarification or add additional context in comments.

Comments

1

Try select query with model

Camera.select('cameras.column1 AS t_column1, cameras.column2 AS t_column2, , count(*) AS total').group('t_column1, t_column2')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.