Hi There, Pretty new to haml. Using it in a Rails 3 app. Trying to figure out the best way to do the following.
I have a place and I want to return it as json, so I have: = raw( {:place => {:uuid => @place.uuid, :name => @place.name, :address => @place.address}}.to_json) This works perfectly Now I want to add a collection of users. I can just use the default .each rendering as follows: = raw( {:place => {:uuid => @place.uuid, :name => @place.name, :address => @place.address}, :matches => [@place.users.each]}.to_json) But I want to be able to pass a closure to .each to set what exactly I want to display for each user. Something like: = raw( {:place => {:uuid => @place.uuid, :name => @place.name, :address => @place.address}, :matches => [@place.users.each do |user| user.email end ]}.to_json) Getting a syntax error on that. I did try overloading to_json on user to deal with the problem elsewhere, but that didn't seem to work. Fairly new to rails, but I'm guessing .each is calling some other method on user to output it as a hash and the to_json is separately being called on the whole response. I also looked into partials, but got escaping issues when I had a render: partial for @place.users.each with backslashes before all of the double quotes. Sure there's a simple solution, just not quite sure what it is. Any input appreciated! Best Wishes, Peter -- You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to haml@googlegroups.com. To unsubscribe from this group, send email to haml+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/haml?hl=en.