Skip to content

Commit

Permalink
Make partial counter start from 0.
Browse files Browse the repository at this point in the history
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
fcheung authored and lifo committed Jun 5, 2008
1 parent df8154c commit 2e0765a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/partial_template.rb
Expand Up @@ -22,10 +22,10 @@ def render
end

def render_member(object)
@locals[@counter_name] += 1
@locals[:object] = @locals[@variable_name] = object

template = render_template
@locals[@counter_name] += 1
@locals.delete(@variable_name)
@locals.delete(:object)

Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/new_render_test.rb
Expand Up @@ -742,7 +742,7 @@ def test_partial_collection

def test_partial_collection_with_counter
get :partial_collection_with_counter
assert_equal "david1mary2", @response.body
assert_equal "david0mary1", @response.body
end

def test_partial_collection_with_locals
Expand All @@ -762,7 +762,7 @@ def test_partial_collection_shorthand_with_locals

def test_partial_collection_shorthand_with_different_types_of_records
get :partial_collection_shorthand_with_different_types_of_records
assert_equal "Bonjour bad customer: mark1Bonjour good customer: craig2Bonjour bad customer: john3Bonjour good customer: zach4Bonjour good customer: brandon5Bonjour bad customer: dan6", @response.body
assert_equal "Bonjour bad customer: mark0Bonjour good customer: craig1Bonjour bad customer: john2Bonjour good customer: zach3Bonjour good customer: brandon4Bonjour bad customer: dan5", @response.body
end

def test_empty_partial_collection
Expand Down

3 comments on commit 2e0765a

@chriseppstein
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have to go and change our code back to expecting a 1-based index. ::sigh::

@jeremy
Copy link
Member

@jeremy jeremy commented on 2e0765a Jun 7, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh? It’s fixed, man — rejoice!!

@ambethia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, I got flustered when I read that the 1-based index was desired behavior*. From the changes here, it looks as if this was an unintended bug after all?
- http://www.ruby-forum.com/topic/154897

Please sign in to comment.