[Rails] Re: how to retrieve single record through chained associations

2009-03-11 Thread Tod Tod
end instead to call self.merchant_category.active Thanks, Tod Tod Tod wrote: > Hi and thanks, > > yes this works Shop.find(2).shop_categories.find_by_category_id(10) > > In shop_categories table I have field 'active' to mark that a category > is visible/active f

[Rails] Re: how to retrieve single record through chained associations

2009-03-08 Thread Tod Tod
> I know that this is not so good solution, but I could not figured out > over way to get this value. It is realy over kill for server. And It > would get harder if there are more values that I need to keep in > merchant_categories. oops, should be shop_categories Tod ps. hmm, here posts do

[Rails] Re: how to retrieve single record through chained associations

2009-03-08 Thread Tod Tod
not figured out over way to get this value. It is realy over kill for server. And It would get harder if there are more values that I need to keep in merchant_categories. Is there a better way to do it? Tod Frederick Cheung wrote: > On Mar 7, 6:08�pm, Tod Tod wrote: >> am

[Rails] Re: how to retrieve single record through chained associations

2009-03-07 Thread Tod Tod
ay of living this kind of chainging. But I is it is not. I'm just guessing but I think this kind of behaviour is in DataMapper, am I right? Tod Frederick Cheung wrote: > On Mar 7, 4:39�pm, Tod Tod wrote: >> >> Logically this kind of chaining >> Shop.find(2).ca

[Rails] Re: how to retrieve single record through chained associations

2009-03-07 Thread Tod Tod
Hi rainer54 Actually Shop.find(1).categories.find(10) and Shop.find(1).categories.find(:first, :conditions => 'category_id = 10') are the different ways to retrieve same category record in association with shop 1. But going further with association I need to retrieve records from shop_catego

[Rails] how to retrieve single record through chained associations

2009-03-07 Thread Tod Tod
Hi I have a standard associations belongs_to, has_many :through class Shop < ActiveRecord::Base has_many :show_categories has_many :categories, :through => :shop_categories end class Category < ActiveRecord::Base has_many :shop_categories has_many :shops, :through => :shop_categories