(Rails)通过“索引”页面就地编辑属性

时间:2009-08-11 01:42:26

标签: ruby-on-rails indexing spreadsheet in-place-edit

我希望在项目的“索引”页面上使用“in_place_editor_field”。基本上我想模拟预先存在的订单项的电子表格功能,以便编辑其属性。但是,我见过的“in_place_editor”示例中没有一个提供这种性质的任何有用的实际应用。

此外,许多现有的代码示例都不起作用。我知道代码已从Core中删除,但即使在将其作为插件安装后,它似乎也没有做任何事情。

有什么想法吗?

最佳。

2 个答案:

答案 0 :(得分:1)

我想做同样的事情。我在http://docs.activestate.com/komodo/5.0/tutorial/railstut.html找到了一个例子 一直滚动到底部,然后查看index.html.erb。

诀窍是in_place_editor_field需要处理实例变量,因此在循环中,您需要设置一个实例变量并将其传递给标记。

答案 1 :(得分:0)

我认为这个例子更好:

<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>

我是从this page

得到的