Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive partial! not working #5

Closed
pctj101 opened this issue Dec 9, 2011 · 3 comments
Closed

recursive partial! not working #5

pctj101 opened this issue Dec 9, 2011 · 3 comments

Comments

@pctj101
Copy link
Contributor

pctj101 commented Dec 9, 2011

Using ree 1.8.7 w/ jbuilder+patches from #4

Lets say we have a nested comment tree (think discussion forum)

Let say we have a file:

index.json.jbuilder

json.comments @comments do |json, comment|
json.partial! "example/comment", :comment => comment
end

Then we have _comment.json.jbilder

json.id comment.id
json.comment comment.text
json.replies comment.replies do |json, reply|
logger.info "Hello" # this prints
json.partial! "example/comment", :comment => reply # this is where we go "recursive"
logger.info "World" # program never makes it this far
end

@pixeltrix
Copy link
Contributor

Ruby 1.8 doesn't have block local variables, so if you use json as a variable name inside the block it will overwrite the parent instance - just been burnt by this myself. :-)

@pctj101
Copy link
Contributor Author

pctj101 commented Dec 9, 2011

oh.... that makes sense... that makes it tougher to do recursive jbuilder with ruby 1.8.

I better start looking at 1.9 sometime I guess

@dhh
Copy link
Member

dhh commented Jan 23, 2012

I'd take a patch to the readme that explains this.

@dhh dhh closed this as completed Jan 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants