One of my views enables searching records using a text field. The rendered view contains only records that match the search. After the view has rendered, I want to add an option to perform an update on the displayed records. The problem is, I don''t know how to figure out which records are shown, since the search form is different from the update form, and I can only submit one of them. Any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
Rails List
2009-Feb-19 13:39 UTC
Re: How can I access currently selected records in the view?
Let us assume you are displaying search results using @mysearchlist and iterate through them. <% @mysearchlist.each do |a| %> <%= link_to a.title, :action => "show", :id => a.id %> <%= link_to ''edit'', :action => "edit", :id => a.id %> <% end %> There you go!. -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the quick response. I''m not sure I follow. My view is rendered with partials, called from search function when the user submits the search: <%= render :partial => ''record'', :collection => @search_results %> -- def search_records # get the search form results from params conds = # formulate the conditions @search_results = Records.find(:all, :conditions => conds) # render the view end Now, a separate form on the page is used to update the shown records. I can''t see how this relates to your answer (then again, I''m new to all this). -- 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 -~----------~----~----~----~------~----~------~--~---
Ar Chron
2009-Feb-19 14:38 UTC
Re: How can I access currently selected records in the view?
sa 125 wrote:> Now, a separate form on the page is used to update the shown records. I > can''t see how this relates to your answer (then again, I''m new to all > this).If you have a separate form on the page for edits, how are you getting the "selected" record into that form for editing? I assume there a list view at the top which returns all those record meeting the search criteria, and below is the editable form. Do you edit one by one, or are you looking for something more like an edit in place within the listing? Haven''t done this myself, so this is all speculation... For one by one, I assume you''ll need some column in the list partial where the action (on click) executes a remote call with that record id and loads that records data into the form portion for editing (discard what was in the form portion, and reload that form part with the "current" records data). Or something like 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 -~----------~----~----~----~------~----~------~--~---
> Do you edit one by one, or are you looking for something more like an > edit in place within the listing? >It''s more like finding the records to update using a filtering form, and then updating some or all the attributes in these records using another update form. More code and explanations in this post: http://railsforum.com/viewtopic.php?id=27309 Feel free to answer there, and I''ll link it here. Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---