You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Rabl and I'm trying to render an OpenStruct object like this (and I'm really not sure If I do this correctly):
collection @all_authentications
@all_authentications.marshal_dump.each do |k,v|
v.each do |attr|
node(k.to_sym) {attributes :id => attr.id, :token => attr.token }
end
end
But this gives me the following error as soon I restart the server and try to load my "authentication" view (haml and json both are throwing this). I have to modify the rabl fike AND to restart the server then, because simply modifying the rabl file does not solve the issue
undefined method `marshal_dump' for nil:NilClass
When I comment the Rabl code out and then restart the server and load my "authenication" view, haml and json do work fine again adn the correct json is delivered.
On the running server I then include the above code again and reload the "authenication" view again, then all is working fine.
So it seems that after a restart the object is nil... I have no clue what is wrong.
thank you in advance
p.
The text was updated successfully, but these errors were encountered:
I just wanted to state that this problem happens because of the apipie gem. When I disable apipie commands, I do not get a blank page anymore.
However executing the code without apipie:
collection @all_authentications
@all_authentications.marshal_dump.each do |k,v|
v.each do |attr|
node(k.to_sym) {attributes :id => attr.id, :token => attr.token }
end
end
now gives me the follwing error:
undefined method `first' for nil:NilClass
Means that I still don't know how to render an openstruct object correctly with rabl and I'm very open for any advise.
UPDATE: when I use object instead of collection then it works. Now I need to find a way to define the node within the first loop not within the second one.
UPDATE2: Looks like that did the trick:
object @all_authentications
@all_authentications.marshal_dump.each do |k,v|
node(k.to_sym) {
v.each do |attr|
attributes :id => attr.id, :token => attr.token
end
}
end
Hi folks!
I'm new to Rabl and I'm trying to render an OpenStruct object like this (and I'm really not sure If I do this correctly):
But this gives me the following error as soon I restart the server and try to load my "authentication" view (haml and json both are throwing this). I have to modify the rabl fike AND to restart the server then, because simply modifying the rabl file does not solve the issue
When I comment the Rabl code out and then restart the server and load my "authenication" view, haml and json do work fine again adn the correct json is delivered.
On the running server I then include the above code again and reload the "authenication" view again, then all is working fine.
So it seems that after a restart the object is nil... I have no clue what is wrong.
thank you in advance
p.
The text was updated successfully, but these errors were encountered: