Andrew Edwards
2008-Sep-12 15:16 UTC
Conditional RJS partial rendering based on request source
Hi, I''m not sure if this is a problem or just part of doing business with an AJAX based interface. I have a create actions that renders a partial via RJS. page.insert_html :top, ''addresses'', { :partial => ''addresses/ address'', :object => @address } However, I call this create method from different points within the application and require the resulting @address object rendered in slightly different ways (coded up in two different partials) depending on which page they made the request. The actual object creation in the create method is the same no matter where it is called but the view needs to differ. Is there an elegant way to handle this without creating two create actions with identical create logic (extract to function?), for example: def checkout_create some_creation_logic responds_to do |format| format.js #renders and inserts address_partial_1 end end def create some_creation_logic responds_to do |format| format.js #renders and inserts address_partial_2 end end 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 -~----------~----~----~----~------~----~------~--~---