ForestAdmin panel shows error when I want to change something in the database

Expected behavior

When I log into ForestAdmin to see the database of my web app, choose a table, click to edit a record and change a field within that record, the change should be saved.

Actual behavior

When I click on save I get the following error (see below) and the change in the record doesn’t get saved.

Context

I only experience this when I’m in the staging or productions environment (web app is hosted on Heroku). In the development environment it works fine.

package.json

{
  "name": "ibiza-garden-houses",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node ./server.js"
  },
  "dependencies": {
    "body-parser": "1.19.0",
    "chalk": "~1.1.3",
    "cookie-parser": "1.4.4",
    "cors": "2.8.5",
    "debug": "~4.0.1",
    "dotenv": "~6.1.0",
    "express": "~4.16.3",
    "express-jwt": "^5.3.1",
    "forest-express": "^7.4.0",
    "forest-express-sequelize": "^6.7.5",
    "morgan": "1.9.1",
    "pg": "~8.2.2",
    "require-all": "^3.0.0",
    "sequelize": "~5.15.1"
  }
}

Hi @OKMantis,

Thank you for sharing your issue with us.

Could I take a look at your staging environment’s backend logs? There might be logs that could help us spot the issue that is happening

Thank you

Right after trying to save a change inside a record within the ForestAdmin panel I get the following logs in Heroku:

2021-01-28T11:36:49.156422+00:00 heroku[router]: at=info method=PUT path="/forest/House/6" host=pacific-crag-46601.herokuapp.com request_id=7cb3c8b7-f642-4068-8fb4-842853b2b365 fwd="67.218.247.241" dyno=web.1 connect=5ms service=33ms status=400 bytes=906 protocol=https
2021-01-28T11:36:49.124344+00:00 app[web.1]: I, [2021-01-28T11:36:49.124229 #4]  INFO -- : [7cb3c8b7-f642-4068-8fb4-842853b2b365] Started PUT "/forest/House/6" for 67.218.247.241 at 2021-01-28 11:36:49 +0000
2021-01-28T11:36:49.125658+00:00 app[web.1]: I, [2021-01-28T11:36:49.125582 #4]  INFO -- : [7cb3c8b7-f642-4068-8fb4-842853b2b365] Processing by ForestLiana::UserSpace::HouseController#update as JSON
2021-01-28T11:36:49.125758+00:00 app[web.1]: I, [2021-01-28T11:36:49.125694 #4]  INFO -- : [7cb3c8b7-f642-4068-8fb4-842853b2b365]   Parameters: {"data"=>{"id"=>"6", "attributes"=>{"sku"=>"ibi-"}, "relationships"=>{"category"=>{"data"=>{"type"=>"Categories", "id"=>"2"}}, "user"=>{"data"=>{"type"=>"Users", "id"=>"1"}}}, "type"=>"Houses"}, "collection"=>"House", "id"=>"6"}
2021-01-28T11:36:49.132343+00:00 app[web.1]: D, [2021-01-28T11:36:49.132272 #4] DEBUG -- : [7cb3c8b7-f642-4068-8fb4-842853b2b365]   e[1me[36mHouse Load (1.0ms)e[0m  e[1me[34mSELECT "houses".* FROM "houses" WHERE "houses"."id" = $1 LIMIT $2e[0m  [["id", 6], ["LIMIT", 1]]
2021-01-28T11:36:49.153915+00:00 app[web.1]: I, [2021-01-28T11:36:49.153776 #4]  INFO -- : [7cb3c8b7-f642-4068-8fb4-842853b2b365] Completed 400 Bad Request in 28ms (Views: 0.4ms | ActiveRecord: 1.8ms | Allocations: 3976)

I also have another issue that might be related to the problem. In the development environment of ForestAdmin I don’t see the last column I’ve added to the houses table. How do I get it to update itself so that shows everything according to the schema in my Rails app?

@OKMantis, I just took a look at your project and it seems that both your production and staging backends are built using forest-rails, and your development backend is built using lumber and forest-express-sequelize.

As your development project is supposed to be pushed to your production server after any addition to your project, ForestAdmin is not intended to have different backend type between your environments.

That being said, I wonder how you managed to create your project using forest-rails last October/November, and now a development environemnt using Lumber and forest-express-sequelize.

However just to answer your questions, as you made your development environment using Lumber, your schema (that populates the UI with your models) is based on the JS models defined in the models folder. It’s not at all related to your rails models. To do so, you’d need a development environment back end made with forest-rails.

It’s weird though that forest-rails is installed in my rails app. I don’t understand how there can be difference between development and staging/production.

I had a commit on the 16th of November 2020:

commit 7ed9ce8b386ec4b05d63293e0a8bdb3cb50a5c16
Author: Owen Moss <owenkmoss@gmail.com>
Date:   Mon Nov 16 12:17:15 2020 +0100

    change in schema forestadmin

diff --git a/Ibiza Garden Houses/.forestadmin-schema.json b/Ibiza Garden Houses/.forestadmin-schema.json
index 1a85484..b45dabf 100644
--- a/Ibiza Garden Houses/.forestadmin-schema.json      
+++ b/Ibiza Garden Houses/.forestadmin-schema.json      
@@ -1124,7 +1124,7 @@
     "liana": "forest-express-sequelize",
     "liana_version": "6.3.13",
     "engine": "nodejs",
-    "engine_version": "12.4.0",
+    "engine_version": "15.2.0",
     "framework": "express",
     "framework_version": "~4.16.3",
     "orm_version": "5.15.2"

I don’t know if that had anything to do with it?

Could you help me undo this situation?

Hello @OKMantis,

To help you solve your problem, could you share with us the logs you have in your browser’s console dev tool? Also if you can share us, if it exists, the request of the network tab that is blocked it would help us to understand the problem.

Thank you ! :slight_smile:

These are the lines that pop up after attempting to change a record:

And this is from the network tab:

hey @OKMantis :wave: your first screenshot issue seem to be similar than Updating records in Rails >= 6.1 fails · Issue #406 · ForestAdmin/forest-rails · GitHub
If you use Rails >= 6.1 I recommend to update your Liana to 5.4.3.

That was it! Thank you so much. :smiley: :fire: :rocket:

2 Likes

I still have issue in the development environment. How can I get this back to normal again?