开发者

How do I make a table with dynamic models editable-in-place in Rails?

开发者 https://www.devze.com 2023-01-21 09:35 出处:网络
This is the view of a table that I have: <% @campaign_events.each do |campaign_event| %> <% model_name = campaign_event.class.name.tableize.singularize %>

This is the view of a table that I have:

<% @campaign_events.each do |campaign_event| %>
    <% model_name = campaign_event.class.name.tableize.singularize %>

  <tr class="<%= cycle('oddrow','evenrow') %>">
    <td><%= link_to campaign_event.title,  send("#{model_name}_path", campaign_event) %></td>
      <td><span class='model_name'><%= model_name.capitalize %></span> 
    <td><center><%= campaign_event.days %></center></td>
    <td><center><%= campaign_event.count_sent%></center></开发者_Go百科td>
  </tr>
  <% end %>
  </table>

@campaign_events can contain an array of several different Model objects: Email, Call, Postalcard, etcetera.

I want to be able to edit the value in campaign_event.days.

I'd like to be able to use some kind of a plugin rather than hand-coding it all, because there are alot of other views that I need to make in-place-editable.

But I'm not sure how to begin with this. This is a key one to begin with.


This is the plugin for in place editing. http://github.com/rails/in_place_editing

0

精彩评论

暂无评论...
验证码 换一张
取 消