{"action":"created","issue":{"url":"https://api.github.com/repos/rails/activerecord-session_store/issues/94","repository_url":"https://api.github.com/repos/rails/activerecord-session_store","labels_url":"https://api.github.com/repos/rails/activerecord-session_store/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/rails/activerecord-session_store/issues/94/comments","events_url":"https://api.github.com/repos/rails/activerecord-session_store/issues/94/events","html_url":"https://github.com/rails/activerecord-session_store/issues/94","id":196264553,"number":94,"title":"Drops validation from belongs_to relations in Rails 5","user":{"login":"mvz","id":10898,"avatar_url":"https://avatars.githubusercontent.com/u/10898?v=3","gravatar_id":"","url":"https://api.github.com/users/mvz","html_url":"https://github.com/mvz","followers_url":"https://api.github.com/users/mvz/followers","following_url":"https://api.github.com/users/mvz/following{/other_user}","gists_url":"https://api.github.com/users/mvz/gists{/gist_id}","starred_url":"https://api.github.com/users/mvz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvz/subscriptions","organizations_url":"https://api.github.com/users/mvz/orgs","repos_url":"https://api.github.com/users/mvz/repos","events_url":"https://api.github.com/users/mvz/events{/privacy}","received_events_url":"https://api.github.com/users/mvz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-18T08:26:52Z","updated_at":"2016-12-18T08:53:34Z","closed_at":null,"body":"In Rails 5, a `belongs_to` relation is automatically validated as required. Adding `activerecord-session_store` to the `Gemfile` of a Rails 5 project removes this automatic validation.\r\n\r\nThis can be reproduced very easily by creating a Rails 5 project with two related models:\r\n\r\n```\r\nrails new quuz\r\ncd quuz\r\nrails g model foo name:string\r\nrails g model bar name:string foo:references\r\n```\r\n\r\nIn the rails console or a test, it can now easily be verified that a Bar object is invalid without a Foo object:\r\n\r\n```\r\nBar.new.valid?                # => false\r\nBar.new(foo: Foo.new).valid?  # => true\r\n```\r\n\r\nIf `activerecord-session_store` is added to the Gemfile like so,\r\n\r\n```\r\ngem 'activerecord-session_store'\r\n```\r\n\r\nthe results are different:\r\n\r\n```\r\nBar.new.valid?                # => true\r\nBar.new(foo: Foo.new).valid?  # => true\r\n```"},"comment":{"url":"https://api.github.com/repos/rails/activerecord-session_store/issues/comments/267810329","html_url":"https://github.com/rails/activerecord-session_store/issues/94#issuecomment-267810329","issue_url":"https://api.github.com/repos/rails/activerecord-session_store/issues/94","id":267810329,"user":{"login":"mvz","id":10898,"avatar_url":"https://avatars.githubusercontent.com/u/10898?v=3","gravatar_id":"","url":"https://api.github.com/users/mvz","html_url":"https://github.com/mvz","followers_url":"https://api.github.com/users/mvz/followers","following_url":"https://api.github.com/users/mvz/following{/other_user}","gists_url":"https://api.github.com/users/mvz/gists{/gist_id}","starred_url":"https://api.github.com/users/mvz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvz/subscriptions","organizations_url":"https://api.github.com/users/mvz/orgs","repos_url":"https://api.github.com/users/mvz/repos","events_url":"https://api.github.com/users/mvz/events{/privacy}","received_events_url":"https://api.github.com/users/mvz/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T08:53:34Z","updated_at":"2016-12-18T08:53:34Z","body":"I've done some debugging, and this seems to have to do with `ActiveRecord::Base` being loaded before `config/initializers/new_framework_defaults.rb` is loaded. If I change the following line in that file:\r\n\r\n```\r\nRails.application.config.active_record.belongs_to_required_by_default = true\r\n```\r\n\r\nto:\r\n\r\n```\r\nActiveRecord::Base.belongs_to_required_by_default = true\r\n```\r\n\r\nthen the validation is restored."}}
{"actor":{"display_login":"mvz"}}