Skip to content

Instantly share code, notes, and snippets.

@manicExpressive
Last active August 29, 2015 14:25
Show Gist options
  • Save manicExpressive/fd82d27d082c463de566 to your computer and use it in GitHub Desktop.
Save manicExpressive/fd82d27d082c463de566 to your computer and use it in GitHub Desktop.
irb(main):056:0> c.posts.all.count
=> 2
irb(main):045:0* x.posts.all.count
=> 0
irb(main):046:0> x.posts.each do |p|
irb(main):047:1* puts p.id
irb(main):048:1> end
=> []
irb(main):049:0> u
=> #<User uuid: "2324bdd0-095f-45d1-b460-ef4a49f8994f", authentication_token: "zo1ksxTiyoYzVcbyHgBh", confirmation_sent_at: nil, confirmation_token: nil, confirmed_at: Thu, 23 Jul 2015 04:47:50 +0000, created_at: Thu, 23 Jul 2015 04:47:51 +0000, current_sign_in_at: Thu, 23 Jul 2015 05:00:43 +0000, current_sign_in_ip: "127.0.0.1", email: "james@threads.dev", encrypted_password: "$2a$10$G2gSbYsP621pxvSqK.EszO6eHvyrTJxZiN9yGZTDAb3S2zgbCxxNy", facebook_token: nil, first_name: "James", last_name: "Madison", last_sign_in_at: Thu, 23 Jul 2015 05:00:43 +0000, last_sign_in_ip: "127.0.0.1", remember_created_at: nil, reset_password_sent_at: nil, reset_password_token: nil, sign_in_count: 26, tos: nil, unconfirmed_email: nil, updated_at: Thu, 23 Jul 2015 05:00:43 +0000>
irb(main):050:0> u.channels.all.count
=> 2
irb(main):051:0> u.channels.each do |c|
irb(main):052:1* puts c.name
irb(main):053:1> puts c.posts.all.count
irb(main):054:1> puts c.posts.first.id
irb(main):055:1> end
Paleo Recipes
2
322aede9-233e-41bc-8387-e8ed18aff53b
So, pedestrian.
2
322aede9-233e-41bc-8387-e8ed18aff53b
@manicExpressive
Copy link
Author

So, channel.posts returns what I would expect, but when you loop through the channels each channel gets all the posts related to the user (one of them is written by u, one is written by another user, both should only belong to the Paleo News channel)?

@manicExpressive
Copy link
Author

Best part: Ember, when it gets any list (/api/v1/channels?owner / postable / member) gives the posts to the last channel in the list because it's models demand only one channel for a post, so they can't be attached to both.

@manicExpressive
Copy link
Author

Individual end points (api/v1/channels/:id) work fine, return the correct result.

@manicExpressive
Copy link
Author

When I add posts to c, both x and c get them. When I add posts to x they don't show up in the index API.

show method still works fine here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment