I have the following query I want to use to create a html list in one of my forms:
concat(contact.lname, ", ", contact.fname) AS name
I know i can use the find_by_sql method of ActiveRecord::Base to accomplish this.
I would, however, like to understand if:
- this is an appropriate use of that method
- the find method can also accomplish this.
- which is the recommended approach.
Here is a little background on the tables & models.
(category_id is a foreign key pointing to lu_contact_categories.id)
class Contact < ActiveRecord::Base
has_one :lu_contact_category, :foreign_key => “id”
class LuContactCategory < ActiveRecord::Base
belongs_to :contact, :foreign_key => “category_id”
Any suggestions are appreciated!