Hi friends, i am using csv export on my application. in my view file code is <%- headers = ["Transaction ID", "Activity ID", "Product Name","Customer Name", "Ticket code"] -%> <%= CSV.generate_line(headers).strip %> <%if !@trans.nil? && @trans.length > 0 %> <% @trans.each do |tran|%> <% if !tran.transaction_id.nil? && tran.transaction_id.present?%><%tran_id = tran.transaction_id%><%else%><%tran_id = "-"%><%end%> <% if !tran.activity_id.nil? && tran.activity_id.present?%><%tran_actid tran.activity_id%><%else%><%tran_actid = "-"%><%end%> <% if !tran.activity_name.nil? && tran.activity_name.present?%><%tran_actname tran.activity_name%><%else%><%tran_actname = "-"%><%end%> <% if !tran.customer_name.nil? && tran.customer_name.present?%><%cus_name tran.customer_name%><%else%><%cus_name = "-"%><%end%> <% if !tran.ticket_code.nil? && tran.ticket_code.present?%><%tran_code tran.ticket_code%><%else%><%tran_code = "-"%><%end%> <%- row = [ tran_id, tran_actid, tran_actname, cus_name, tran_code ] -%> <%#= CSV.generate_line(row).html_safe.strip%> <%end%> <%else%> Sorry we found no results <%end%> now i got 5 extra empty rows how can avoid the empty rows. thanks for advance. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJyRp%2B2XWWevjSM76ow5kjmDSsfzeKya_rCbENa8zpENPOg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On 8 November 2013 06:24, Daynthan Kabilan <dayanthan86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi friends, > > i am using csv export on my application. in my view file code is > > > <%- headers = ["Transaction ID", "Activity ID", "Product Name","Customer > Name", "Ticket code"] -%> > <%= CSV.generate_line(headers).strip %> > <%if !@trans.nil? && @trans.length > 0 %> > <% @trans.each do |tran|%> > > <% if !tran.transaction_id.nil? && tran.transaction_id.present?%><%tran_id > tran.transaction_id%><%else%><%tran_id = "-"%><%end%> > <% if !tran.activity_id.nil? && tran.activity_id.present?%><%tran_actid > tran.activity_id%><%else%><%tran_actid = "-"%><%end%> > <% if !tran.activity_name.nil? && > tran.activity_name.present?%><%tran_actname > tran.activity_name%><%else%><%tran_actname = "-"%><%end%> > <% if !tran.customer_name.nil? && tran.customer_name.present?%><%cus_name > tran.customer_name%><%else%><%cus_name = "-"%><%end%> > <% if !tran.ticket_code.nil? && tran.ticket_code.present?%><%tran_code > tran.ticket_code%><%else%><%tran_code = "-"%><%end%> > > <%- row = [ tran_id, tran_actid, tran_actname, cus_name, tran_code ] > -%> > <%#= CSV.generate_line(row).html_safe.strip%> > <%end%> > <%else%> > Sorry we found no results > <%end%> > > now i got 5 extra empty rows how can avoid the empty rows.Do you mean that @trans.count is 5 less than the number of rows generated? If you, for example, include something like puts "@trans.count = #{@trans.count}" in the code then this will be displayed in the server window. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsxa6vf%2BLU%2BhfMLxu8sXK9WD1w%3DEnDc-r1BhX636px7UQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On Nov 8, 2013, at 12:24 AM, Daynthan Kabilan <dayanthan86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi friends, > > i am using csv export on my application. in my view file code is > > > <%- headers = ["Transaction ID", "Activity ID", "Product Name","Customer Name", "Ticket code"] -%> > <%= CSV.generate_line(headers).strip %> > <%if !@trans.nil? && @trans.length > 0 %> > <% @trans.each do |tran|%> > > <% if !tran.transaction_id.nil? && tran.transaction_id.present?%><%tran_id = tran.transaction_id%><%else%><%tran_id = "-"%><%end%> > <% if !tran.activity_id.nil? && tran.activity_id.present?%><%tran_actid = tran.activity_id%><%else%><%tran_actid = "-"%><%end%> > <% if !tran.activity_name.nil? && tran.activity_name.present?%><%tran_actname = tran.activity_name%><%else%><%tran_actname = "-"%><%end%> > <% if !tran.customer_name.nil? && tran.customer_name.present?%><%cus_name = tran.customer_name%><%else%><%cus_name = "-"%><%end%> > <% if !tran.ticket_code.nil? && tran.ticket_code.present?%><%tran_code = tran.ticket_code%><%else%><%tran_code = "-"%><%end%> > > <%- row = [ tran_id, tran_actid, tran_actname, cus_name, tran_code ] -%> > <%#= CSV.generate_line(row).html_safe.strip%> > <%end%> > <%else%> > Sorry we found no results > <%end%> > > now i got 5 extra empty rows how can avoid the empty rows. > > thanks for advance.Seems like this would be a lot easier to deal with as a helper than all this code in the view in ERB. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/EEE7DFD7-E014-4A56-A74B-5C1E2D3BFE7E%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Maybe Matching Threads
- [PATCH v4 0/6] tests/qemu: Add program for tracing and analyzing boot times.
- [PATCH v3 0/11] tests/qemu: Add program for tracing and analyzing boot times.
- weird postgres adapter error
- [RFC] [PATCH] Add btrfs autosnap feature
- Error: uninitialized constant MysqlCompat::MysqlRes