Skip to content

Commit

Permalink
POC for busted partial rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
meagar committed Jan 24, 2017
1 parent 68b89fe commit 23933af
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

def index
a = {}
b = {}
def a.to_partial_path; 'a'; end
def b.to_partial_path; 'b'; end

@het_collection = [a, b]
@hom_collection = [a, a]
end
end
5 changes: 5 additions & 0 deletions app/views/application/_a.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<li style="color: <%= defined?(a_iteration) ? "#090" : "#f00" %>">
<h3>/app/views/application/_a.html.erb</h3>
defined?(a_iteration):
<%= defined?(a_iteration) %>
</li>
5 changes: 5 additions & 0 deletions app/views/application/_b.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<li style="color: <%= defined?(b_iteration) ? "#090" : "#f00" %>">
<h3>/app/views/application/_b.html.erb</h3>
defined?(b_iteration):
<%= defined?(b_iteration) %>
</li>
13 changes: 13 additions & 0 deletions app/views/application/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<code>
<h2>render [a, a]</h2>
<ul><%= render @hom_collection %></ul>

<h2>render [a, b]</h2>
<ul><%= render @het_collection %></ul>

<h2>render partial: [a, a]</h2>
<ul><%= render partial: @hom_collection %></ul>

<h2>render partial: [a, b]</h2>
<ul><%= render partial: @het_collection %></ul>
</code>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'application#index'
end

0 comments on commit 23933af

Please sign in to comment.