{"action":"closed","issue":{"url":"https://api.github.com/repos/joker1007/activemodel-associations/issues/3","labels_url":"https://api.github.com/repos/joker1007/activemodel-associations/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/joker1007/activemodel-associations/issues/3/comments","events_url":"https://api.github.com/repos/joker1007/activemodel-associations/issues/3/events","html_url":"https://github.com/joker1007/activemodel-associations/issues/3","id":61934577,"number":3,"title":"Inheriting from a Base class fails","user":{"login":"jufemaiz","id":16481,"avatar_url":"https://avatars.githubusercontent.com/u/16481?v=3","gravatar_id":"","url":"https://api.github.com/users/jufemaiz","html_url":"https://github.com/jufemaiz","followers_url":"https://api.github.com/users/jufemaiz/followers","following_url":"https://api.github.com/users/jufemaiz/following{/other_user}","gists_url":"https://api.github.com/users/jufemaiz/gists{/gist_id}","starred_url":"https://api.github.com/users/jufemaiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jufemaiz/subscriptions","organizations_url":"https://api.github.com/users/jufemaiz/orgs","repos_url":"https://api.github.com/users/jufemaiz/repos","events_url":"https://api.github.com/users/jufemaiz/events{/privacy}","received_events_url":"https://api.github.com/users/jufemaiz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-16T01:17:48Z","updated_at":"2015-11-05T02:58:57Z","closed_at":"2015-11-05T02:58:57Z","body":"Hi, thanks for the work. To DRY my code, I created a base class:\r\n\r\n```\r\nclass Star < ActiveRecord::Base\r\nend\r\n\r\nrequire 'active_model'\r\n\r\nclass Awesome::Base\r\n  extend ActiveModel::Naming\r\n  extend ActiveModel::Callbacks\r\n  include ActiveModel::Model\r\n  include ActiveModel::Associations\r\n  include ActiveModel::Conversion\r\n  include ActiveModel::Dirty\r\n  include ActiveModel::Validations\r\n  \r\n  # need hash like accessor, used internal Rails\r\n  #\r\n  # @param attr [?] blah\r\n  # @return ?\r\n  def [](attr)\r\n    self.send(attr)\r\n  end\r\n\r\n  # need hash like accessor, used internal Rails\r\n  #\r\n  # @param attr [?] blah\r\n  # @return ?\r\n  def []=(attr, value)\r\n    self.send(\"#{attr}=\", value)\r\n  end\r\n\r\nend\r\n```\r\n\r\nNow, I want to have:\r\n\r\n```\r\nclass Awesome::Planet < Awesome::Base\r\n  belongs_to :star\r\nend\r\n```\r\n\r\nHowever I'm getting the following:\r\n\r\n```\r\nNoMethodError: undefined method `[]' for nil:NilClass\r\n\tfrom /.../gems/activemodel-associations-0.1.0/lib/active_model/associations/override_methods.rb:96:in `association_instance_get'\r\n\tfrom /.../gems/activemodel-associations-0.1.0/lib/active_model/associations/override_methods.rb:57:in `association'\r\n\tfrom /.../gems/activerecord-4.2.0/lib/active_record/associations/builder/association.rb:115:in `star'\r\n\tfrom (irb):3\r\n\tfrom /.../gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'\r\n\tfrom /.../gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'\r\n\tfrom /.../gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'\r\n\tfrom /.../gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'\r\n\tfrom /.../gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'\r\n\tfrom bin/rails:4:in `require'\r\n\tfrom bin/rails:4:in `<main>'\r\n```\r\n\r\nThe @association_cache is not being initialized (staying as nil, haence the \"undefined method '[]'\" issue).\r\n\r\nAny thoughts?"}}