http
http copied to clipboard
JSON view block
json @worlds.map do |world|
Views::World.new(world)
end
Is treated as builder variant and
json @worlds.map { |world| Views::World.new(world) }
Is not.
Also doesn't work for
json tips: @tips.map do |tip|
View::Tip.new(tip)
end
7. def render_to_application_json(io : IO)
> 8. ({tips: @tips.map}).to_json(io)
9. end
'Array(Models::Tip)#map' is expected to be invoked with a block, but no block was given
Should put more thought into it. Given:
json content_type: "application/json-a" do
builder do
field "foo", @foo
field "bar", @bar
end
end
What if I just wanted to add builder block arg?
json content_type: "application/json-a" do |builder|
builder do
field "foo", @foo
field "bar", @bar
end
end