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
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to