Error just after installing Forest

  • After going through the ForestAdmin install steps, I see all the collections in Forest but no data.

Expected behavior

  • See the data related to the selected collection

Actual behavior

  • “Cannot reach your data” error message

Failure Logs

Started OPTIONS "/forest/User?fields%5BUser%5D=authentication_token%2Ccreated_at%2Cemail%2Cfirst_name%2Cid%2Cip_address%2Clast_name%2Cpassword_digest%2Csuperuser%2Ctenant%2Cupdated_at%2Cuser_agent&fields%5Btenant%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-id&timezone=Europe%2FBrussels" for ::1 at 2021-02-08 15:23:05 +0100
Started GET "/forest/User?fields%5BUser%5D=authentication_token%2Ccreated_at%2Cemail%2Cfirst_name%2Cid%2Cip_address%2Clast_name%2Cpassword_digest%2Csuperuser%2Ctenant%2Cupdated_at%2Cuser_agent&fields%5Btenant%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-id&timezone=Europe%2FBrussels" for ::1 at 2021-02-08 15:23:05 +0100
Processing by ForestLiana::UserSpace::UserController#index as JSON
  Parameters: {"fields"=>{"User"=>"authentication_token,created_at,email,first_name,id,ip_address,last_name,password_digest,superuser,tenant,updated_at,user_agent", "tenant"=>"name"}, "page"=>{"number"=>"1", "size"=>"15"}, "searchExtended"=>"0", "sort"=>"-id", "timezone"=>"Europe/Brussels", "collection"=>"User"}
No template found for ForestLiana::UserSpace::UserController#index, rendering head :no_content
Completed 204 No Content in 1ms (ActiveRecord: 0.0ms | Allocations: 667)


Started OPTIONS "/forest/User/count?fields%5BUser%5D=authentication_token%2Ccreated_at%2Cemail%2Cfirst_name%2Cid%2Cip_address%2Clast_name%2Cpassword_digest%2Csuperuser%2Ctenant%2Cupdated_at%2Cuser_agent&fields%5Btenant%5D=name&searchExtended=0&timezone=Europe%2FBrussels" for ::1 at 2021-02-08 15:23:05 +0100
Started GET "/forest/User/count?fields%5BUser%5D=authentication_token%2Ccreated_at%2Cemail%2Cfirst_name%2Cid%2Cip_address%2Clast_name%2Cpassword_digest%2Csuperuser%2Ctenant%2Cupdated_at%2Cuser_agent&fields%5Btenant%5D=name&searchExtended=0&timezone=Europe%2FBrussels" for ::1 at 2021-02-08 15:23:05 +0100
Processing by ForestLiana::UserSpace::UserController#count as HTML
  Parameters: {"fields"=>{"User"=>"authentication_token,created_at,email,first_name,id,ip_address,last_name,password_digest,superuser,tenant,updated_at,user_agent", "tenant"=>"name"}, "searchExtended"=>"0", "timezone"=>"Europe/Brussels", "collection"=>"User"}
   (0.2ms)  SELECT COUNT(*) FROM "users"
Completed 200 OK in 2ms (Views: 0.1ms | ActiveRecord: 0.2ms | Allocations: 1275)

Context

Please provide any relevant information about your setup.

  • Rails Version: 6.1.1
  • Database Dialect: Postgres
  • Database Version: 13.1
  • Project Name: Flexio

Hi @jbescoyez !
You have Cannot reach your data displayed ?
The logs you shared are not error logs, do you have any other log ? What about your browser logs ?

Yes, I do have Cannot reach your data displayed.

I think the issue is at this line:

No template found for ForestLiana::UserSpace::UserController#index, rendering head :no_content

How comes the template is not found and therefore no content is sent?

Nothing special in my browser logs (just an error with Drift):

Can you share the UserController class please ?

Not sure to get you. Do you mean the ForestLiana::UserSpace::UserController or my UserController?

If it is mine, I am not sure it will help. I have the same behavior for all collections.

You are right, I won’t see anything there.
Your issue looks a lot like this one.
Are you using fast_jsonapi ?

Yes, I do. Does it mean that Forest is not compatible with the most famous jsonapi lib in Rails?

Actually it should, can you try changing mount ForestLiana::Engine => '/forest' to mount ForestLiana::Engine => '/forest', defaults: { format: 'json' } in your routes.rb ?

Let me know if it works !

Thank you. It solved the problem but another one arose. :confused:

Now, I get the following error:

Records Index error: undefined local variable or method `object' for #<ForestLiana::UserSpace::DocumentSerializer:0x00007ff83db0cfd8>
Did you mean?  object_id
/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/forest_liana-5.4.3/app/serializers/forest_liana/serializer_factory.rb:63:in `type'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/jsonapi-serializers-1.0.1/lib/jsonapi-serializers/serializer.rb:406:in `serialize_primary'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/jsonapi-serializers-1.0.1/lib/jsonapi-serializers/serializer.rb:438:in `block in serialize_primary_multi'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/jsonapi-serializers-1.0.1/lib/jsonapi-serializers/serializer.rb:438:in `map'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/jsonapi-serializers-1.0.1/lib/jsonapi-serializers/serializer.rb:438:in `serialize_primary_multi'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/jsonapi-serializers-1.0.1/lib/jsonapi-serializers/serializer.rb:321:in `serialize'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/forest_liana-5.4.3/app/controllers/forest_liana/application_controller.rb:46:in `serialize_models'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/forest_liana-5.4.3/app/controllers/forest_liana/resources_controller.rb:227:in `render_jsonapi'
	/Users/johndoe/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/forest_liana-5.4.3/app/controllers/forest_liana/resources_controller.rb:36:in `block (2 levels) in index'
...

I’ve dug a bit and realized that you use GitHub - fotinakis/jsonapi-serializers: Pure Ruby readonly serializers for the JSON:API spec. and I use GitHub - jsonapi-serializer/jsonapi-serializer: A fast JSON:API serializer for Ruby (fork of Netflix/fast_jsonapi) (the new name of fast_jsonapi). The two libraries define the following constant JSONAPI::Serializer with a different API.

I do not really know what to do. What do you recommend?

Hey @jbescoyez,

Thanks for taking the time to look into it. I created an issue, you can follow its progress here:

Hey @vince Is it still under your radar? Tnx :slight_smile:

Hi @jbescoyez, sorry we delayed this topic, waiting for a dedicated Rails developer to join the team.
As we didn’t find the right teammate (yet), I think we’ll have to prioritise the investigations about this issue and have a look at it next week.

1 Like

Hi @jbescoyez, the team is still looking for the appropriate solution here.
There is no easy win, but we are getting closer to decide how to prevent this conflict.

Indeed, I already thought what I could do and it is surely not easy.

Thanks for investigating. I am sure it will benefit other users since https://github.com/jsonapi-serializer/jsonapi-serializer is now the go to serializer for any JSONAPI Ruby backend.

Sent from Front

1 Like

Hi @arnaud! Any update? Tnx :slight_smile:

Hey @jbescoyez,

We are currently working on it. I opened a PR available here that still need some work in order to be fully operational. It might also introduce a breaking change, meaning it’ll be available in the beta release, hopefully this week.

You can definitely try it out though, using the github path or by cloning the forest rails repo and installing the gem via

gem 'forest_liana', path: 'path/to/your/forest/rails/clone/forest-rails'

This is far from a perfect solution, but be sure that we are still working on it.

Let me know if you try it, any feedback will be appreciated :raised_hands:

1 Like

I have just tested it and everything is running smoothly. Tnx!

3 Likes

Good to know it works.

I’ll update the thread once a proper release is done then. Thanks for your feedback :pray:

This is released in 7.0.0.beta.1.
Keep in mind that this is a beta, so it might include other breaking changes by the time it is released :raised_hands: