{"action":"created","issue":{"url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1085","labels_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1085/labels{/name}","comments_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1085/comments","events_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1085/events","html_url":"https://github.com/phoenixframework/phoenix/issues/1085","id":98811578,"number":1085,"title":"Better error message when rendering `Ecto.Association.NotLoaded`","user":{"login":"paulcsmith","id":22394,"avatar_url":"https://avatars.githubusercontent.com/u/22394?v=3","gravatar_id":"","url":"https://api.github.com/users/paulcsmith","html_url":"https://github.com/paulcsmith","followers_url":"https://api.github.com/users/paulcsmith/followers","following_url":"https://api.github.com/users/paulcsmith/following{/other_user}","gists_url":"https://api.github.com/users/paulcsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/paulcsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulcsmith/subscriptions","organizations_url":"https://api.github.com/users/paulcsmith/orgs","repos_url":"https://api.github.com/users/paulcsmith/repos","events_url":"https://api.github.com/users/paulcsmith/events{/privacy}","received_events_url":"https://api.github.com/users/paulcsmith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-08-03T18:32:45Z","updated_at":"2015-08-03T19:14:02Z","closed_at":null,"body":"I was working with some views in Phoenix 0.14.0 and I called `render_one(post.comments, \"index.son\")`\r\n\r\nI got an error along the lines of `MyApp.NotLoadedView` module does not exist. I was not sure why it was trying to call that view when I passed in comments and later realize it was because I did not preload the `comments` association.\r\n\r\nI think it would be nice if it raised a helpful error message when you passed an `Ecto.Association.NotLoaded` as the model to `render_one` or `render_many`. *I can tackle this on Friday if this is something that you think would be helpful.*\r\n\r\n```elixir\r\npost = Repo.one(Post)\r\nrender_one(post.comments, \"index.json\")\r\n# I believe it should raise something like:\r\n# \"You tried to render Ecto.Association.NotLoaded. \r\n# This probably means you forgot to preload the record. Try using Repo.preload\"\r\npost = post |> Repo.preload(:comments)\r\nrender_one(post.comments, \"index.json\")\r\n# Works as expected\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/phoenixframework/phoenix/issues/comments/127375921","html_url":"https://github.com/phoenixframework/phoenix/issues/1085#issuecomment-127375921","issue_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1085","id":127375921,"user":{"login":"josevalim","id":9582,"avatar_url":"https://avatars.githubusercontent.com/u/9582?v=3","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"created_at":"2015-08-03T19:14:02Z","updated_at":"2015-08-03T19:14:02Z","body":"@paulcsmith please hold on, @chrismccord and I are considering dropping the inflection because it is causing a lot of confusion."}}