Reputation: 4567
I am trying to use the RABL gem for JSON formatting, but even this simple basic example is not working.
Here is for instance a test method in the controller:
def test
@test={:a=>"toto",:b=>"titi"}
respond_to do |format|
format.json
end
end
and here is the rabl
object @test
attributes :a,:b
The result is here:
[{"titi":{}},{"titi":{}}]
In fact, I've made several tries and the same type of result, just like if the filed name were not taken in account....
Upvotes: 0
Views: 488
Reputation: 6355
I wrote a blog post on this, explaining the issue, and how to get around it:
http://bigtrapeze.com/2012/03/22/using-rabl-to-display-multiple-models/
Upvotes: 2
Reputation: 4567
The developper solver my problem: RABL does not work with hash objects, only dotted object ( myObj.myField and not myObj[:myField]). The solution was to convert the hash into an OpenStruct object
Upvotes: 1