-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST url's incorrect #241
Comments
Hmm, I've managed (somehow) to get the POST going to the correct URL, but now there's an issue when GET'ing the next resource. I have this URL: /users/1/books/1/chapters My User has_many :books, and a Book has_many :chapters (book belongs_to :user, and chapter belongs_to :book in my Her models). If I look at the object returned by User.find(1).books, the @parent variable is set to 'users/1'. For User.find(1).books.find(1).chapters, the @parent variable is set to 'chapters/1'. That seems correct to me, but I would assume the subsequent call to fetch the chapters would join these parent paths together. My Her models are:
On the API side, each of the resources, apart from User, has the foreign_key for its parent resource (ie /users/1/books/1 has user_id, /users/1/books/1/chapters/1 has book_id). Can resources be nested deeply, or is only 1 level supported? thanks. |
Replying to myself again :) This is now returning data from the resources, however calling:
returns an object like Chapter(< unknown path, missing I'm trying to figure out why the Book->Chapter relationship is causing problems (unlike the User->Book one) but I can't find anything wrong in my code. Is this a bug in Her? |
I have a couple Her::Model's User and Book's. A user has_many :books, and I can retrieve them with User.find(1).books => [Book, Book....]
However, User.find(1).books.create(title: "test book") sends a GET request to /users
This is pretty much the same as the example code, so I dont think I'm doing anything wrong in my code. Is there a known issue?
Many thanks!
The text was updated successfully, but these errors were encountered: