I have a model called Campaign. In the controller, I do the following to list, in order, the three Models that belong_to
a Campaign:
<% @campaign_events = campaign_events %>
<% @campaign_events.each do |campaign_event| %>
<% model_name = campaign_event.class.name.tableize.singularize %>
<p>
<%= link_to campaign_event.title, send("#{model_name}_path", campaign_event) %>
<span class='model_name'>(<%= model_name.capitalize %>)</span>
<%= campaign_event.days %> Days
</p>
<% end %>
campaign_event is a campaign_helper
defined as:
module CampaignsHelper
def campaign_events
return (@campaign.calls + @campaign.emails + @campaign.letters).sort{|a,b| a.days <=> b.days}
end
end
I want to be able to click on the numerical value for Days when looking at the view/campaign/show and edit the value for :days
(in this case, displayed as campaign_event.days