Hello!
I’m a little new to rails and have a strange problem i’m trying to
decipher.
I have a Project model and Category model, connected together by a HABTM
(with a categorys_projects join table)
Rails is doing everything as it should, apart from the find.
Am I wrong to think that I should be able to go:-
projects = Project.find_all_by_category(some_id)
As the only way I can return projects of a certain category right now is
using
a join like so :
projects = Project.find(:all, joins => :categories, :conditions =>
{:categories => { :id => params[:category] } })
Where:-
class Project < ActiveRecord::Base
has_and_belongs_to_many :categories
end
class Category < ActiveRecord::Base
has_and_belongs_to_many :projects
end
Bit confused!
Any help would be great
Thanks!
K