Answer the question
In order to leave comments, you need to log in
Rails calling Postgresql method?
I need to call a postgres method from rails.
categories = Entity.joins(:language, :category).
select("coalesce('entities.short_descr', 'categories.short_descr')").
where('languages.code = ?', 'en')
render json: {status: 'ok', categories: categories}
{"status":"ok","categories":[{"coalesce":"entities.short_descr","id":null}]}
Answer the question
In order to leave comments, you need to log in
....select("coalesce('entities.short_descr', 'categories.short_descr') as short_descr, entities.* ")....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question