After writing some of the large and complex SQL statements that I once asked, how could I do it better with Rails . However, in the end, I again used Arel because I couldn’t put in more conditions if I called find_by_sql.
Questions.find_by_sql(HUGE_SQL).by_filter(:popular).order('created_at').limit(5)
My goals:
- Sort sqls in separate files
- Convert these string sqls to arel objects
- The nest of this object isl with the usual reusable conditions such as "limit, order, .."
thanks
source share