I’m converting a PHP app written in CodeIgniter to Rails.
Due to the size of the application and the inability to makes change to the schema, I’m not interested in making models for each entity.
I want to be able to do CodeIgniter style queries like this (Supply a pre-written query and associated variables):
query("SELECT * FROM posts WHERE id = ?", id)
and get a result back.
I know that it’s highly suggested to use models and do it “the rails way”, and I definitely plan to for my next application that I write from scratch in Rails, but for this project I want to avoid the ORM and just have the ability to do direct queries using the database connection.
What would be the best way to do this?
I hate myself for not having the willpower to not answer this question, so just quickly:
Use ActiveRecord#find_by_sql