samordonez / reading-list-api

Rails API for managing reading lists
https://sofistication.github.io/book-next/
Other
0 stars 0 forks source link

Users can only update books for which they have a reading #6

Closed samordonez closed 7 years ago

samordonez commented 7 years ago

Presumably due to BooksController inheriting from OpenReadController, attempting to update a book for which the user does not have a reading results in a 404 with the following server error:

Started PATCH "/books/4" for 127.0.0.1 at 2017-02-21 11:02:32 -0500
Processing by BooksController#update as */*
  Parameters: {"book"=>{"title"=>"BookFour", "author"=>"Maynard Ingram", "published_in"=>"2017", "description"=>"CHANGED"}, "id"=>"4"}
  User Load (1.0ms)  SELECT  "users".* FROM "users" WHERE "users"."token" = $1 LIMIT $2  [["token", "3edc3f67efb5221c5ef55a7cfc20ea7a"], ["LIMIT", 1]]
  Book Load (1.3ms)  SELECT  "books".* FROM "books" INNER JOIN "readings" ON "books"."id" = "readings"."book_id" WHERE "readings"."user_id" = $1 AND "books"."id" = $2 LIMIT $3  [["user_id", 2], ["id", 4], ["LIMIT", 1]]
[active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.17ms)
Completed 404 Not Found in 19ms (Views: 5.9ms | ActiveRecord: 2.3ms)
samordonez commented 7 years ago

solved by #9