Skip to content

Commit ec218d6

Browse files
committed
Log the collection type that goes into the grid partial. Sometimes it's a searchresultswrapper and other times it's a AR relation. :|
1 parent b56a5bb commit ec218d6

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

app/views/protips/_grid.html.haml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
-reset_protip_result_index
2-
-show_job = defined?(opportunity) && !opportunity.nil?
1+
- reset_protip_result_index
2+
- show_job = defined?(opportunity) && opportunity.present?
33
- width = (defined?(width) && width) || 4
4-
- show_ad_every = width*2+width-2
5-
- items = show_job ? protips.each_slice(show_ad_every).map{|row| row.count == show_ad_every ? row.concat(['show-ad', nil]) : row }.flatten : protips
4+
- show_ad_every = width * 2 + width - 2
5+
- items = show_job ? protips.each_slice(show_ad_every).map{ |row| row.count == show_ad_every ? row.concat(['show-ad', nil]) : row }.flatten : protips
66

7-
- if collection.failure?
7+
- logger.ap(collection, :debug)
8+
- if collection.respond_to?(:failure?) && collection.failure?
89
.error
9-
="#{collection.error} Meanwhile you can "
10-
=link_to 'create a pro tip', new_protip_path
10+
= "#{collection.error} Meanwhile you can "
11+
= link_to 'create a pro tip', new_protip_path
1112
= "about #{@topic}" unless @topic.nil?
1213

13-
-items.in_groups_of(width, nil).each_with_index do |group, row|
14-
-if (row > 0) && blur_protips?
14+
- items.in_groups_of(width, nil).each_with_index do |group, row|
15+
- if (row > 0) && blur_protips?
1516
.blurred-tips
16-
=render :partial => "sessions/join_buttons", :locals => {:message => "Join to start earning badges for your open source contributions, discover protips and connect with other developers"}
17-
-break
17+
= render(partial: 'sessions/join_buttons', locals: { message: 'Join to start earning badges for your open source contributions, discover protips and connect with other developers' })
18+
- break
1819
%ul.protips-grid.cf
19-
-group.each do |protip|
20-
-if protip == 'show-ad'
21-
=render :partial => 'opportunities/mini', :locals => {:opportunity => opportunity}
22-
-elsif !protip.nil?
20+
- group.each do |protip|
21+
- if protip == 'show-ad'
22+
= render(partial: 'opportunities/mini', locals: { opportunity: opportunity })
23+
-elsif protip.present?
2324
- if protip = protip.load rescue nil # HACK: User deleted, protip no longer exists. Won't be found.
24-
%li{:class => (protip.kind == 'link' ? 'ext-link' : '') }
25-
= render :partial => 'protips/mini', :locals => {:protip => protip, :mode => mode}
25+
%li{ class: (protip.kind == 'link' ? 'ext-link' : '') }
26+
= render(partial: 'protips/mini', locals: { protip: protip, mode: mode })
2627

2728
- unless collection.nil? || !collection.respond_to?(:next_page) || collection.next_page.nil? || hide_more
28-
- next_url = url_for(params.merge(:tags=> params[:tags], :q => params[:q], :source => params[:action], :controller =>params[:controller], :page => collection.current_page + 1, :section => (defined?(section) ? section : nil), :width => width, :mode => mode ))
29-
%div{:class => ("#{number_to_word(width)}-cols-more" unless width.nil?)}
30-
#more=link_to 'More', next_url, :class => 'final-more track' , :rel => 'next', :remote => true, :method => (params[:action] == "search" ? :post : :get), 'data-action' => 'more protips', 'data-from' => params[:action]
29+
- next_url = url_for(params.merge(tags: params[:tags], q: params[:q], source: params[:action], controller:params[:controller], page: collection.current_page + 1, section: (defined?(section) ? section : nil), width: width, mode: mode ))
30+
%div{ class: ("#{number_to_word(width)}-cols-more" unless width.nil?) }
31+
#more= link_to('More', next_url, class: 'final-more track', rel: 'next', remote: true, method: (params[:action] == 'search' ? :post : :get), 'data-action' => 'more protips', 'data-from' => params[:action])

0 commit comments

Comments
 (0)