{"action":"opened","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18696","labels_url":"https://api.github.com/repos/rails/rails/issues/18696/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18696/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18696/events","html_url":"https://github.com/rails/rails/issues/18696","id":55591983,"number":18696,"title":"Provide better error message on :required association","user":{"login":"noinkling","id":4338251,"avatar_url":"https://avatars.githubusercontent.com/u/4338251?v=3","gravatar_id":"","url":"https://api.github.com/users/noinkling","html_url":"https://github.com/noinkling","followers_url":"https://api.github.com/users/noinkling/followers","following_url":"https://api.github.com/users/noinkling/following{/other_user}","gists_url":"https://api.github.com/users/noinkling/gists{/gist_id}","starred_url":"https://api.github.com/users/noinkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noinkling/subscriptions","organizations_url":"https://api.github.com/users/noinkling/orgs","repos_url":"https://api.github.com/users/noinkling/repos","events_url":"https://api.github.com/users/noinkling/events{/privacy}","received_events_url":"https://api.github.com/users/noinkling/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-27T09:03:23Z","updated_at":"2015-01-27T09:03:23Z","closed_at":null,"body":"The `:required` option introduced for `belongs_to`/`has_one` associations (#16056) is very nice, however it still uses the default error message from the presence validator - \"... can't be blank\" - which doesn't make much sense for associations. It would be much nicer to have a default message like \"... doesn't exist\" or something along those lines.\r\n\r\nChanging the locale string works, but of course it still doesn't let you differentiate between presence validations on associations and presence validations on normal model attributes. Additionally, there's no support for setting the message manually on a case-by-case basis like with the normal validation syntax.\r\n\r\nI understand that it's supposed to be a simple option and that if someone wants the other options they can just go back to the old validation syntax, but I think it provides a good opportunity to use a different default message.\r\n\r\nBecause the `:required` option [calls `validates_presence_of` behind the scenes](https://github.com/rails/rails/blob/00f55516509770f58f9ce462d45afb80d8f649ca/activerecord/lib/active_record/associations/builder/singular_association.rb#L34), I think you could just add the `:message` option to that call, but I don't know how to integrate that with the I18n stuff, hence no pull request.\r\n\r\n/cc @sgrif "}}