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.