I have a many to many relationship between users and accounts. When I create these records on sign up, I am able to see the id of the account I just created in the json for the users I just created, but I am not able to see the user ids in the account json I just created. I am trying to create these records with the associated ids. I am using Sinatra for the back end. This is my first time asking a question so my apologies if my question isn’t clear or code snippets aren’t formatted correctly. Here’s what I have:

This seems fine. Are you sure your Serializer is handling relationship correctly? Is the relationship set up working on GET?

Are you trying to determine if the relationship setup has worked by your console.log calls in register action? If you are not using client-side generated IDs, your records won’t have IDs at that point of time cause the requests are async. I would recommend using ember-inspector.

I have ember inspector. The only id that shows is the one for the record itself. I am able to access the account id for the user by using ‘user.record.id’(not sure if that’s the way to go) but I am not able to access the user data for accounts.

Would be helpful if you could setup an ember-twiddle reproducing your issue. Could you please try to do so? You could use ember-cli-mirage in ember-twiddle for mocking your api. There is a boilerplate twiddle for mirage.

This was great! Thank you. My issue was that I couldn’t see the accounts associated with the user but when I change the twiddle to return all ‘users’ and change the templates accordingly and it displays the account associated with the users. However, when I apply it to my app, the correct information is displayed but when i refresh it, the ‘li’ elements disappear. For example, the accounts route no longer shows the users and vice versa. I’m not sure if that would be a different topic.

I tried SO first and put 2 questions because I didn’t feel as if my first question was clear enough. But I didn’t get a response on either one so I tried this site. Again, I’m new to this so just trying to figure out what works. I’ll delete the questions. But thanks again for your help!