Hi,
I have a object with children. some of these children are empty...so
when i paginate them, i get blanks. is there a way to strip out the
empty children? these are my debug. thanks.
- !ruby/object:Scategory
attributes:
name: bbq
id: "2"
mcategory_id: "2"
howtos: []
- !ruby/object:Scategory
attributes:
name: baking
id: "3"
mcategory_id: "2"
howtos:
- !ruby/object:Howto
attributes:
scategory_id: "3"
title: Carrot cake so good.
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
it seems basically i need to run a compact on the children, but how to use compact on children? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
poipu wrote:> I have a object with children. some of these children are empty...so > when i paginate them, i get blanks. is there a way to strip out the > empty children? these are my debug. thanks.I have been having so much fun with Array#reject recently... ;-) -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
poipu wrote:> it seems basically i need to run a compact on the children, but how to > use compact on children?Put them into an Array? If they are in a Model, such as a product of has_many, they likely are already in an Array. Post some Ruby code (not YAML!). -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yes, it is a model. but im still trying to grasp the concept..... i am calling this.. @scats = Scategory.find(:all, :conditions => ["mcategory_id = ?", params[:id]], :include => :howtos) howtos are the children....scategory has many howtos.... now scats is an array where the content is an array of howtos contents? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
poipu wrote:> @scats = Scategory.find(:all, :conditions => ["mcategory_id = ?", > params[:id]], :include => :howtos) > > howtos are the children....scategory has many howtos.... > > now scats is an array where the content is an array of howtos contents?p scats.first p scats.first.howtos p scats.first.howtos.first Next question: What is an "empty" howto? Can you add a :condition or similar to the has_many to exclude them at the database level? Or - even better - not store them? -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---