I wrote a find_by_sql query as I didn't manage to do it with ActiveRecord so I have in city_controller:
but I would like to move the sql query to the model city as it is more a class thing than a controller. How to do that?PHP Code:
query = "SELECT distinct c.* FROM cities as c LEFT JOIN properties as p ON p.city_id = c.id WHERE p.city_id IS NOT NULL"
@cities = City.find_by_sql query