marmelab / ng-admin-postgrest

Demo of an integration between ng-admin and PostgREST
http://marmelab.com/ng-admin-postgrest
111 stars 15 forks source link

HTTP 405 when editing entities #2

Open nicolov opened 9 years ago

nicolov commented 9 years ago

Thanks for the great job, ng-admin is very slick.

In any case, I've set-up ng-admin 0.7.0 with postgrest 0.2.11.1 according to this demo repo. Creating new entities works fine, but editing existing ones fails with:

Oops, an error occured : (code: 405) You must speficy all and only primary keys as params

My table schema:

 Column |  Type   |                       Modifiers                       
--------+---------+-------------------------------------------------------
 id     | integer | not null default nextval('customer_id_seq'::regclass)
 name   | text    | 

My ng-admin config snippet:

        var customer = nga.entity('customer');

        app.addEntity(customer);

        customer.listView()
            .perPage(10)
            .fields([
                nga.field('id'),
                nga.field('name')
            ])
            .listActions(['edit', 'show']);

        customer.showView()
            .fields([
                nga.field('id'),
                nga.field('name')
            ]);

        customer.creationView()
            .fields([
                nga.field('name')
            ]);

        customer.editionView()
            .fields(customer.creationView().fields());
fzaninotto commented 9 years ago

ping @brikou

begriffs commented 8 years ago

Changing the code from using the PUT verb to PATCH will fix the problem. In fact puts are no longer supported in v3 because their benefit vs code complexity isn't high enough.