(Rails) In-place editing of attributes via an "index" page

1.6k views Asked by At

I'm looking to use "in_place_editor_field" on an "Index" page of items. Basically I want to mimic spreadsheet functionality for pre-existing line items in order to edit their attributes. However, none of the "in_place_editor" examples I've seen provide any useful real-world application of this nature.

Also, a lot of the existing code examples don't work. I'm aware that the code was removed from Core, but even after installing it as a plugin, it doesn't seem to do anything.

Any ideas?

Best.

2

There are 2 answers

0
Roman Zabicki On BEST ANSWER

I wanted to do the same thing. I found an example at http://docs.activestate.com/komodo/5.0/tutorial/railstut.html Scroll all the way to the bottom and look at index.html.erb.

The trick is that in_place_editor_field needs to work on an instance variable, so inside your loop, you need to set an instance variable and pass that to the tag.

0
Claudio Shigueo Watanabe On

I think that this example is better:

<table>
    <tr>   
        <th>First name</th>   
        <th>Last name</th> 
    </tr>  
    <% @person.each do |person| %>
        <tr>  
            <td><%= best_in_place person, :first_name %></td>  
            <td><%= best_in_place person, :last_name %></td>
        </tr>
    <% end %>
</table>

I got this from this page