I got it working.

Controller - just fetches sub categories based on the given category
id.
 Returns @sub_category to the view.


View - it decides if a subcategory select box is to be displayed or
not based
on the size of the array ie. if @subcategory.length >0

I will try out "@sub_categories.blank?" to see if it works too or not.
Thanks ,Sijo kg!



> QUESTION:  How do you test if a given collection of objects is defined
> in Ruby?
> ==========================================================
> In the case above in my controller method, it's @sub_categories - how
> do I test that there are entries in it?
>
> I have tried using 'nil' by means of  "if �...@sub_categories.nil" and
> "if �...@sub_categories == nil".
> I have tried using 'defined?' by means of "if defined?
> @sub_categories".
>
> Both do not work.
> In the world of perl (where I am from), I could test the variable for
> truth  (ie something like "if ( $sub_categories )" ).
>
> Please help, guys!
--~--~---------~--~----~------------~-------~--~----~
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