sferik/rails_admin — Issue #911: STI problem saving from child model edit page
Author: BM5k
Created: 2012-01-03 22:00:25+00:00
State: open

I'm having the opposite problem from #462.

With a Parent model and a Child model, if I make changes on ```/admin/child/1/edit```, the save fails with no error, if I make the same changes on ```/admin/parent/1/edit``` changes are saved as expected.

When saving from the child model's edit page, there are no UPDATE sql statements:

```
Started PUT "/admin/child/16/edit" for 127.0.0.1 at 2012-01-03 15:40:32 -0600
Processing by RailsAdmin::MainController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+lpAomZOVYkL6q5WTyFdabf1ymNkVgblTtQL23uTbLQ=", "parent"=>{"attr1"=>"value1", "attr2"=>"value2"}, "return_to"=>"http://localhost:3000/admin/child", "_save"=>"", "model_name"=>"child", "id"=>"16"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 LIMIT 1
Child Load (0.2ms) SELECT "parents".* FROM "parents" WHERE "parents"."type" IN ('Child') AND "parents"."id" = 16 LIMIT 1
Redirected to http://localhost:3000/admin/child
Completed 302 Found in 1067ms
```

When saving from the parent model's edit page there are UPDATEs executed:

```
Started PUT "/admin/parents/16/edit" for 127.0.0.1 at 2012-01-03 15:45:52 -0600
Processing by RailsAdmin::MainController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+lpAomZOVYkL6q5WTyFdabf1ymNkVgblTtQL23uTbLQ=", "parent"=>{"attr1"=>"value1", "attr2"=>"value2"},, "return_to"=>"http://localhost:3000/admin/parents", "_save"=>"", "model_name"=>"parents", "id"=>"16"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 LIMIT 1
Parent Load (0.1ms) SELECT "parents".* FROM "parents" WHERE "parents"."id" = 16 LIMIT 1
(0.4ms) UPDATE "parents" SET "attr1" = 'value1', "attr2" = 'value2', "updated_at" = '2012-01-03 21:45:53.612193' WHERE "parents"."type" IN ('Child') AND "parents"."id" = 16
SQL (1.5ms) INSERT INTO "rails_admin_histories" ("created_at", "parent", "message", "month", "table", "updated_at", "username", "year") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["created_at", Tue, 03 Jan 2012 14:45:53 MST -07:00], ["parent", 16], ["message", "Changed attr1, attr2"], ["month", nil], ["table", "Parent"], ["updated_at", Tue, 03 Jan 2012 14:45:53 MST -07:00], ["username", "admin@testing.com"], ["year", nil]]
Redirected to http://localhost:3000/admin/parents
Completed 302 Found in 797ms
```

I am seeing the "... was successfully updated" flash message in *both* cases, so I apologize if this is a duplicate of #558, I am not seeing the ```Uninitialized Constant``` errors like #361.

This is with 87aff45576e914d63997735731d3a21f7ecf4390 and the current HEAD (cd2eaa2b2903c315cf15f283088c20abf22822c4)