{"issue":{"created_at":"2011-09-09T17:49:46Z","state":"closed","updated_at":"2011-12-07T10:51:43Z","user":{"gravatar_id":"cb1e5ab82814fa5c0be3a10538841ce8","id":25550,"url":"https://api.github.com/users/gaizka","login":"gaizka","avatar_url":"https://secure.gravatar.com/avatar/cb1e5ab82814fa5c0be3a10538841ce8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":0,"body":"Hi there!\r\n\r\nI wanted to make this work:\r\n\r\n    module MyCorp\r\n      class Factory; end\r\n      class Company; end\r\n\r\n      class Employee; end\r\n    end\r\n    \r\n    class MyCorp::EmployeesController < InheritedResources::Base\r\n      belongs_to :factory, :company, :polymorphic => true\r\n    end\r\n\r\nMaybe it's an extreme case, i am not sure. Anyway, it was not working up to now. \r\n\r\nWhen it loads the resources_configuration, it would never find the :parent_class for the :factory or :company models (it would search for `Company`, instead of `MyCorp::Company`).\r\n\r\nI've patched class_methods.rb to make it work. If you think the patch should be improved, please tell me and i'll try to do it. Now, if regular lookup fails, it tries to find the model in the same namespace as the widget.\r\n\r\nI've added a test file also, `test/polymorphic_test_with_namespaced_model.rb` that's basically a copy of `test/polymorphic_test.rb` with the models namespaced.\r\n\r\nThere are some failing tests, but they were there before the patch :)\r\n\r\ngaizka/inherited_resources@c936b70acd44b64a3d207bfdd8845bed63c89bec\r\n\r\nThanks a lof for inherited_resources!! It has saved so many of my life's hours :)","assignee":null,"number":167,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"id":1609827,"labels":[],"title":"Namespaced models and controllers in a polymorphic belongs_to relationship don't work","html_url":"https://github.com/josevalim/inherited_resources/issues/167","closed_at":"2011-12-07T10:51:43Z","url":"https://api.github.com/repos/josevalim/inherited_resources/issues/167","milestone":null},"action":"closed"}