HerModel.all raises Errors on json request:
I have a very simple model:
class InternalUser
include Her::Model
parse_root_in_json true, format: :active_model_serializers
end
It's api call returns very simple json:
[{"user_name":"user_a"},{"user_name":"user_b"},{"user_name":"user_c"}]
The controller should just render this json:
respond_to :json
def index
@internal_users = InternalUser.all
respond_to do |format|
format.json { render :json => @internal_users }
end
end
Very simple.
As stated above, calls return: no implicit conversion of Symbol into Integer
Removing the parse_root directive in the model returns ActiveSupport::JSON::Encoding::CircularReferenceError
I've traced both conditions but not sure why ActiveSupport is thinking you've defined a circular reference. I'm not seeing it in the model passed in to json_encode.
The Symbol Into Integer is being thrown from: lib/her/model/parse.rb:122:in [] which is the extract_array method called by parse_root_in_json
Was there a miss somewhere? Can you get the above to behave correctly?
We're experiencing the same issue. I've managed to get around it by suffixing the collection with .fetch.
respond_to :json
def index
@internal_users = InternalUser.all
respond_to do |format|
format.json { render :json => @internal_users.fetch }
end
end