rubyonrailsin

A Ruby and Rails talk

Thursday, April 1, 2010


[Rails] Best way of sorting/grouping objects

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

I have a Model called Page, which has a column called page_type.
I want to display all pages by page type (which can change/be added).

What is the best way of doing this? I was, in the view looping through
each page_type, then doing an SQL search for a Page with that
page_type. But I don't want to call Models through the View..

I tried to create a laid out like this:

@hash[:type1] = {:object1_id => object, :object2_id => object }
@hash[:type2] = {:object1_id => object, :object2_id => object }

etc.

Then using a partial to go through the types.. but I'm getting errors.

Anyone have a good idea of how to do this?

Thanks

--
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@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

Subscribe feeds via e-mail

Blog Archive