This project is archived and is in readonly mode.
Partial collection counter variable improperly named using :as
Reported by graham (at votary) | June 16th, 2009 @ 01:13 AM | in 2.3.6
This is my first bug submission, so please forgive any deviations from protocol.
It seems that the :as option doesn't affect the counter variable name when rendering a collection. Here is an example.
From a brand new 2.3.2 app...
# [ApplicationController#index]
<% @cheesecakes = %w(strawberry chocolate graham-cracker) %>
<%= render :partial => "item", :collection => @cheesecakes, :as => :cheesecake %>
# [application/_item.html.erb]
<%= "#{item_counter+1} #{cheesecake}" %>
</br>
[OUTPUT]
1 strawberry
2 chocolate
3 graham-cracker
Should this "item_counter" not be "cheesecake_counter"? Instead "cheesecake_counter" does not exist.
undefined local variable or method `cheesecake_counter'
Comments and changes to this ticket
-
Dan Pickett May 9th, 2010 @ 07:12 PM
- Tag changed from 2-3-stable, partial, partial_counter, render to 2-3-stable, bugmash, partial, partial_counter, render
-
Jeff Kreeftmeijer May 15th, 2010 @ 10:49 AM
- Tag changed from 2-3-stable, bugmash, partial, partial_counter, render to 2-3-stable, bugmash, master, partial, partial_counter, render, verified
Verified on master and 2-3-stable using the code snippet Graham provided.
-
Jeff Kreeftmeijer May 15th, 2010 @ 12:36 PM
I've attached a patch that allows you to use
cheesecake_counter
in addition toitem_counter
in the above example for master. I'm working on a patch for 2-3-stable as we speak. -
Jeff Kreeftmeijer May 15th, 2010 @ 01:19 PM
Sorry, was using wrong ticket numbers in my commit messages so I removed the patches. Here they are again.
-
Jeff Kreeftmeijer May 15th, 2010 @ 01:21 PM
- no changes were found...
-
Anil Wadghule May 15th, 2010 @ 01:41 PM
+1 for this patch. I verified it against Rails master. It definitely helps in improving readability of code.
-
Rizwan Reza May 15th, 2010 @ 05:03 PM
- Tag changed from 2-3-stable, bugmash, master, partial, partial_counter, render, verified to 2-3-stable, bugmash, bugmash-review, master, partial, partial_counter, render, verified
- State changed from new to verified
-
Jeremy Kemper May 15th, 2010 @ 06:32 PM
- Milestone changed from 3.x to 2.3.6
-
Repository May 15th, 2010 @ 06:33 PM
- State changed from verified to resolved
(from [fa99de0bd054576336c940ca78f3d1b35b6e490e]) partial counters with :as [#2804 state:resolved]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/fa99de0bd054576336c940ca78f3d1... -
Repository May 15th, 2010 @ 06:33 PM
(from [2de364636c06487faf48cbf9198bccd90a02eaf8]) partial counters with :as [#2804 state:resolved]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/2de364636c06487faf48cbf9198bcc... -
Rizwan Reza May 15th, 2010 @ 06:35 PM
- Tag changed from 2-3-stable, bugmash, bugmash-review, master, partial, partial_counter, render, verified to 2-3-stable, master, partial, partial_counter, render, verified
-
Jeremy Kemper May 15th, 2010 @ 06:44 PM
- State changed from resolved to incomplete
Fix failing tests.
-
Jeff Kreeftmeijer May 15th, 2010 @ 07:11 PM
Needed to check if
as
is set before trying to create a counter for it. I’ve attached a patch. :) -
Repository May 15th, 2010 @ 07:22 PM
- State changed from incomplete to resolved
(from [5d7ad7ba41c1c4298ad6467d63ee20e6c6acdbfd]) make sure
as
is set before trying to build an #{as}_counter. [#2804 state:resolved]Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/5d7ad7ba41c1c4298ad6467d63ee20... -
Repository May 15th, 2010 @ 07:22 PM
(from [da90fe94662b338a2430e99ff0d3298059a28a51]) make sure
as
is set before trying to build an #{as}_counter. [#2804 state:resolved]Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/da90fe94662b338a2430e99ff0d329...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 2804 Partial collection counter variable improperly named using :as (from [fa99de0bd054576336c940ca78f3d1b35b6e490e]) partial...
- 2804 Partial collection counter variable improperly named using :as (from [2de364636c06487faf48cbf9198bccd90a02eaf8]) partial...
- 2804 Partial collection counter variable improperly named using :as (from [5d7ad7ba41c1c4298ad6467d63ee20e6c6acdbfd]) make su...
- 2804 Partial collection counter variable improperly named using :as (from [da90fe94662b338a2430e99ff0d3298059a28a51]) make su...