Need help on rjs calls and partials

Hey all -

What I’m trying to accomplish is creating my own edit in place on a set
of data. Right now I’m just toying with some nonsense app, but when I
figure it out it’ll be put to good use. I divide my code between the
view, the partial, the controller and the rjs template. For the sake of
example, I have a list of products and I’m trying to enable editing
their names:

# in the view

Product List

<%= render :partial => 'product', :collection => @products, :locals => {:edit_mode => false }}%>
<%= link_to_function 'edit', go_to_edit_mode %>

in the partial

<% @product = product %>

<% if edit_mode -%> <%= text_field :product, :name, :size => 10 %> <% else -%> <%= product.name %> <% end -%>

#in the controller (_product.html.erb)
def go_to_edit_mode
@prods = Product.find(:all)
respond_to do |format|
format.html { render :partial => ‘product’,
:collection => @prods,
:locals => {:edit_mode => false }}
format.js
end
end

in the rjs (go_to_edit_mode.js.rjs)

page.replace_html ‘prod-table’,
:partial => ‘product’,
:collection => Product.find(:all, :order => ‘name’),
:edit_mode => true

This is hardly working, though I think I’m going in the right
direction… Someone whos a seasoned rails developer will probably see
the problems right away, but since I’m new, I’d very much appreciate any
help I could get here - thanks.