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….
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