Ruby on Rails Tuesday, January 3, 2012

Thank you Peter. I have some follow up questions.


Let's say I would use a scope. How could I do that? (let's ignore the "image_small" for now and focus on the subcategory) There is nothing in the product table that I can use to select the completed products. It is only regarded as completed if the related resellercategory is associated to a subcategory. So, in the scope I would need to join the resellercategories table and check if that is associated with a subcategory.

Feels a bit unnecessary to do that for a small thing as this. But maybe it won't affect the performance that much.


The other option I was thinking of was just to add an after_filter in resellercategory model like this:

  def update_products
    self.products.each(&:save)
  end

I'll see if I can get the scope to work first.

Regards
Linus

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/kF4xK7oJ7UEJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment