I''m doing some editing on an existing rails app and this view; _tour_listing.html.erb looks like this: <% if @upcoming_tour_requests.blank? %> <p>No upcoming tour requests.</p> <% else %> <table> <tr> <th>Group Name</th> <th>Contact Name</th> <th>Status</th> <th>Date</th> <th>Actions</th> </tr> <%= render :partial => "tour_listing", :collection => @upcoming_tour_requests %> </table> <% end %> <h3>Other Active Tour Requests</h3> <p>Tour requests not scheduled to take place within the next two weeks, but still having a status of initial, received, or confirmed:</p> <% if @tour_requests.blank? %> <p>No other active tour requests.</p> <% else %> <table> <tr> <th>Group Name</th> <th>Contact Name</th> <th>Status</th> <th>Date</th> <th>Actions</th> </tr> <%= render :partial => "tour_listing", :collection => @tour_requests %> </table> <% end %> My question is with the render :partial => etc... line. I need to find away to sort the data that is getting spit out by a specific field, how would I do that? -- 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 -~----------~----~----~----~------~----~------~--~---
How about making the <th> a remote link and have a action that pulls the @tour_requests sorted from the parameter and then update the partial div. ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> My question is with the render :partial => etc... line. I need to find > away to sort the data that is getting spit out by a specific field, how > would I do that?You''ll want to do that when the data is marshalled, not in the view or parital code... look into the controller to see how your data is retrieved. Then, the model whose is being displayed should be able to provide the data in the desired order... -- 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 -~----------~----~----~----~------~----~------~--~---
Quoting Ryan Ororie <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > I''m doing some editing on an existing rails app and this view; > _tour_listing.html.erb looks like this:[snip]> My question is with the render :partial => etc... line. I need to find > away to sort the data that is getting spit out by a specific field, how > would I do that? >Sort it in the controller or model, wherever the find() is. Often: @upcoming_tour_requests = TourRequests.find(:all, :order => ''date'') Anything SQL accepts can go in the :order value, ''date DESC'', ''id'', etc. Another point, blank? is for strings, empty? is standard Ruby for arrays. HTH, Jeffrey --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---