search for: find_by_categori

Displaying 5 results from an estimated 5 matches for "find_by_categori".

Did you mean: find_by_category
2006 Apr 13
2
Automatic finder
It looks rails automatically creates a "finder" method on models that have a "belongs_to". So I tried this in the console: c = Category.find(2) chunks = Chunk.find_by_category(c) chunks is always returned as an empty array. When I know have some chunks with a category_id of 2. Should the find_by_category do what I think it should be doing or am I completely off base?
2005 Dec 16
3
Adding methods to models
All, This is more of a theoretical question I suppose - I''m looking for what the consensus is for the "correct" approach in Rails/MVC. I have a standard security model where a User can have many Roles. There is a User model, a Role model, and in the db, a linking table, etc. Each role has a name as well as a category (say, name="waiter", category="restaurant
2006 Apr 06
3
has_and_belongs_to_many find
Say I have a post model that has_and_belongs_to_many :categories, and a category model that has_and_belongs_to_many :posts. So I have a categories_posts table to do the join. That''s all find and dandy. However I want to be able to find all the posts that belong to a specific category. I tried Post.find_by_category(:id) but that doesn''t work. Does anyone have any insight?
2006 Apr 13
3
Sorting an array of models
I have a model, listing, which belongs_to one or more categories. I need the user to be able to search for categories by name (which I can do) and have it return all the listings that belong to those categories. This I can do. However, what I need to do is take that list of listings and sort them by one of their fields. This is a bit more complicated, without needing to sort I could just do:
2006 May 01
3
Routing requests without ID parameter
Hi there, This seems to be obvious but after reading a few times the section in the Agile Wb Dev with Rails I''m still strugling. I have a table with categories names which I want to display in the url instead of their id. So far I managed to get both in the url by adding: map.connect ''/:id/:category/'', :controller => "site", :action =>