{"action":"created","issue":{"url":"https://api.github.com/repos/sxross/MotionModel/issues/141","repository_url":"https://api.github.com/repos/sxross/MotionModel","labels_url":"https://api.github.com/repos/sxross/MotionModel/issues/141/labels{/name}","comments_url":"https://api.github.com/repos/sxross/MotionModel/issues/141/comments","events_url":"https://api.github.com/repos/sxross/MotionModel/issues/141/events","html_url":"https://github.com/sxross/MotionModel/issues/141","id":131140018,"number":141,"title":"has_one relationship not working","user":{"login":"holgersindbaek","id":698979,"avatar_url":"https://avatars.githubusercontent.com/u/698979?v=3","gravatar_id":"","url":"https://api.github.com/users/holgersindbaek","html_url":"https://github.com/holgersindbaek","followers_url":"https://api.github.com/users/holgersindbaek/followers","following_url":"https://api.github.com/users/holgersindbaek/following{/other_user}","gists_url":"https://api.github.com/users/holgersindbaek/gists{/gist_id}","starred_url":"https://api.github.com/users/holgersindbaek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holgersindbaek/subscriptions","organizations_url":"https://api.github.com/users/holgersindbaek/orgs","repos_url":"https://api.github.com/users/holgersindbaek/repos","events_url":"https://api.github.com/users/holgersindbaek/events{/privacy}","received_events_url":"https://api.github.com/users/holgersindbaek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-03T20:17:21Z","updated_at":"2016-02-04T17:51:55Z","closed_at":null,"body":"I'm having some issues with the following models.\r\n\r\n    class Listing\r\n      include MotionModel::Model\r\n      include MotionModel::ArrayModelAdapter\r\n\r\n      # Colums\r\n      columns :headline\r\n\r\n      # Relationships\r\n      has_one :user, dependent: :destroy\r\n    end\r\n\r\n    class User\r\n      include MotionModel::Model\r\n      include MotionModel::ArrayModelAdapter\r\n\r\n      columns :first_name\r\n\r\n      belongs_to :listing\r\n    end\r\n\r\nIf I do the following:\r\n\r\n    listing = Listing.create(headline: \"Some headline\")\r\n    listing.user.create(first_name: \"Some name\")\r\n    listing.user\r\n    listing.user.first_name\r\n\r\nI get the following error:\r\n    \r\n    (main)> listing.user\r\n=> #<MotionModel::ArrayFinderQuery:0x11fb47850 @field_name=:listing_id @collection=[User#1:0x11f9943e0] @related_object=Listing#61:0x11fd00840 @klass=User>\r\n    (main)> listing.user.first_name\r\n2016-02-03 15:16:12.938 Slang[55648:459275] undefined method `first_name' for #<MotionModel::ArrayFinderQuery:0x11f774240 ...> (NoMethodError)\r\n=> #<NoMethodError: undefined method `first_name' for #<MotionModel::ArrayFinderQuery:0x11f774240 ...>>\r\n\r\nWhat is going on here? Why is the user not returned when I do \"listing.user\"?"},"comment":{"url":"https://api.github.com/repos/sxross/MotionModel/issues/comments/179965308","html_url":"https://github.com/sxross/MotionModel/issues/141#issuecomment-179965308","issue_url":"https://api.github.com/repos/sxross/MotionModel/issues/141","id":179965308,"user":{"login":"holgersindbaek","id":698979,"avatar_url":"https://avatars.githubusercontent.com/u/698979?v=3","gravatar_id":"","url":"https://api.github.com/users/holgersindbaek","html_url":"https://github.com/holgersindbaek","followers_url":"https://api.github.com/users/holgersindbaek/followers","following_url":"https://api.github.com/users/holgersindbaek/following{/other_user}","gists_url":"https://api.github.com/users/holgersindbaek/gists{/gist_id}","starred_url":"https://api.github.com/users/holgersindbaek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holgersindbaek/subscriptions","organizations_url":"https://api.github.com/users/holgersindbaek/orgs","repos_url":"https://api.github.com/users/holgersindbaek/repos","events_url":"https://api.github.com/users/holgersindbaek/events{/privacy}","received_events_url":"https://api.github.com/users/holgersindbaek/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T17:51:55Z","updated_at":"2016-02-04T17:51:55Z","body":"If I do 'listing.user.first', then I get the user and everything works as expected. Issue I have with that, is that in a 'has_one' relationship, there is only 1 user and therefore it's weird to me that you have to get the first user, as if it's an array.\r\n\r\nIt seems to me that the 'has_one' relationship is acting exactly like the 'has_many' relationship."}}