write a block method to print a list
def column (&block)
if block_given?
content_tag(:li, capture(self, &block))
else
content_tag(:li, "")
end
end
and using it as
<%= data_list_for @leads, [" :10", "Age:30",
"Contact:140", "Phone:
140", "Email:180", "Company:100", ""] do |l|
%>
<%= l.column { |c| link_to " ".html_safe,
"leads/details/
#{c.object.id}", :class=>:plus, :remote=>true } %>
<%= l.column { |c| c.object.age } %>
<%= l.column { |c| c.object.contact.complete_name } %>
<%= l.column { |c| c.object.contact.phones.blank? ? "-" :
c.object.contact.phones.first.phone_number } %>
<%= l.column { |c| c.object.contact.emails.blank? ? "-" :
c.object.contact.emails.first.email } %>
<%= l.column { |c| c.object.company.title } %>
<%= l.column do |c| %>
<%= options_menu do |m| %>
<%= m.item link_to ''Show'', lead_path(c.object)
%>
<%= m.item link_to ''Edit'',
edit_lead_path(c.object) %>
<%= m.item link_to ''New Note'',
"leads/#{c.object.id}/notes/
new", :class=>"display-newxdoc", :id=>c.object.id %>
<%= m.item link_to ''Create Opportunity'',
new_lead_opportunity_path(c.object) %>
<% end %>
<% end %>
<% end %>
Every thing is working fine. But the only problem is that options_menu
is generating twice. Means two option_menus are there. I traced out
one menu is from l.column command because it has proper formating of
column, other is generating by its on block in the view, How can i
stop it for doing twice?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.