Hi
I have 2 models which have a has_and_belongs_to_many
relation:
class Category < ActiveRecord::Base
has_and_belongs_to_many :templates
end
class Template < ActiveRecord::Base
has_and_belongs_to_many :categories
end
I want to know how can I get a category name through this relation, for example I find a first template:
t = Template.find(:first)
Then using t.categories
will return an object, but I want to have category.name in return, how can I achieve this?