I am using rjs to perform ajax deletes on objects within an array @instructions. The objects within the array @instructions vary depending on some other logic in my controller and is not dependent on direct correlations within the database. In other words, when I update the partial with: page.replace_html :instructions, :partial => ''instructions'', :collection => @instructions The @instructions cannot just be populated by active record correlations such as: @day.instructions. The logic used in the controller to populate the @instructions variable is expensive and I would prefer not to go through the logic again if possible. What is the best option for this situation, would using some caching method be best, or is there a way to store the @instructions variable in a flash or params or something? 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-/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 -~----------~----~----~----~------~----~------~--~---
David wrote:> I am using rjs to perform ajax deletes on objects within an array > @instructions. The objects within the array @instructions vary > depending on some other logic in my controller and is not dependent on > direct correlations within the database. In other words, when I > update the partial with: > > page.replace_html :instructions, :partial => > ''instructions'', :collection => @instructions > > The @instructions cannot just be populated by active record > correlations such as: > @day.instructions. > > The logic used in the controller to populate the @instructions > variable is expensive and I would prefer not to go through the logic > again if possible. What is the best option for this situation, would > using some caching method be best, or is there a way to store the > @instructions variable in a flash or params or something?Probably the best way would be to cache the whole HTML partial using Rails'' partial-cache capability. You would use a custom cache key that''s built on the set of controller parameters that influence the contents of the @instructions collection. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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 -~----------~----~----~----~------~----~------~--~---
OK, thanks. I actually solved the problem by just deleting the html with: page[dom_id(@instruction)].remove. On Nov 14, 5:01 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> David wrote: > > I am usingrjsto perform ajax deletes on objects within an array > > @instructions. The objects within the array @instructions vary > > depending on some other logic in my controller and is not dependent on > > direct correlations within the database. In other words, when I > > update the partial with: > > > page.replace_html :instructions, :partial => > > ''instructions'', :collection => @instructions > > > The @instructions cannot just be populated by active record > > correlations such as: > > @day.instructions. > > > The logic used in the controller to populate the @instructions > > variable is expensive and I would prefer not to go through the logic > > again if possible. What is the best option for this situation, would > > using some caching method be best, or is there a way to store the > > @instructions variable in a flash or params or something? > > Probably the best way would be to cache the whole HTML > partial using Rails'' partial-cache capability. You would > use a custom cache key that''s built on the set of controller > parameters that influence the contents of the @instructions > collection. > > -- > Rails Wheels - Find Plugins, List & Sell Plugins -http://railswheels.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---