I have a class
class DataListBuilder
include ActionView::Helpers::TagHelper
include ActionView::Helpers::CaptureHelper
include ActionView::Helpers::UrlHelper
attr_accessor :object, :output_buffer
def initialize(object)
@object, @output_buffer = object, nil
end
def column (&block)
if block_given?
content_tag(:li, block.call(self))
else
content_tag(:li, "")
end
end
def options_column(&link_block)
if block_given?
content_tag(:li, content_tag(:dl, "<dt><a href='#'> </a></dt><dd><ul>#{link_block.call(self)}</ul></dd>".html_safe, :class=>'options'))
else
content_tag(:li, "")
end
end
def link_item(title, url, options={})
content_tag :li, link_to(title, url, options)
end
end
and calling it as
<%= l.options_column do |c| %>
<%= c.link_item 'Show', lead_path(c.object) %>
<%= c.link_item 'Edit', edit_lead_path(c.object) %>
<%= c.link_item 'New Note', "leads/#{c.object.id}/notes/new", :class=>"display-newxdoc", :id=>c.object.id %>
<%= c.link_item 'Create Opportunity', new_lead_opportunity_path(c.object) %>
<% end %>
the desired output is
<li><dl class="options"><dt><a href="#"> </a></dt><dd><ul style="display: none;">
<li><a data-remote="true" class="plus" href="leads/details/309"> </a></li>
<li>3w</li>
<li>Simon Wu</li>
<li>1-714-553-0888</li>
<li>omnisw@unifiedbeat.com</li>
<li>Unified Beat</li>
<li><a href="/leads/309">Show</a></li>
<li><a href="/leads/309/edit">Edit</a></li>
<li><a id="309" class="display-newxdoc" href="leads/309/notes/new">New Note</a></li>
<li><a href="/leads/309/opportunities/new">Create Opportunity</a></li>
but it is generating
<li><a href="/leads/309">Show</a></li>
<li><a href="/leads/309/edit">Edit</a></li>
<li><a id="309" class="display-newxdoc" href="leads/309/notes/new">New Note</a></li>
<li><a href="/leads/309/opportunities/new">Create Opportunity</a></li>
<li><dl class="options"><dt><a href="#"> </a></dt><dd><ul style="display: none;">
<li><a data-remote="true" class="plus" href="leads/details/309"> </a></li>
<li>3w</li>
<li>Simon Wu</li>
<li>1-714-553-0888</li>
<li>omnisw@unifiedbeat.com</li>
<li>Unified Beat</li>
<li><a href="/leads/309">Show</a></li>
<li><a href="/leads/309/edit">Edit</a></li>
<li><a id="309" class="display-newxdoc" href="leads/309/notes/new">New Note</a></li>
<li><a href="/leads/309/opportunities/new">Create Opportunity</a></li>
</ul></dd></dl></li>
</ul></dd></dl></li>
Can any one help me in it.
Complete code is listed here.