Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opaque NoMethodError on nil when a resource-bound model's associations lack corresponding resources #31

Open
xeger opened this issue Jun 7, 2018 · 0 comments

Comments

@xeger
Copy link

xeger commented Jun 7, 2018

Given the following erroneous resource definitions:

class Document < ActiveRecord::Base
  belongs_to User
end

class User < ActiveRecord::BAse
end

module Resources
  class Document
    model ::Document
  end

I would hope that praxis-mapper would check its model map for nil before calling methods and perhaps raise an easy-to-understand error such as "you're missing a resource definition, you ninny!" Instead I get a gnarly backtrace that I must decode myself:

#<NoMethodError: undefined method `properties' for nil:NilClass>
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:30:in `map_property'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:21:in `block in add'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:20:in `each'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:20:in `add'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:87:in `add_association'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:33:in `map_property'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:21:in `block in add'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:20:in `each'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/selector_generator.rb:20:in `add'
praxis-mapper-b73ad03c2606/lib/praxis-mapper/identity_map.rb:557:in `add_selectors'
praxis-f677785df9f2/lib/praxis/extensions/mapper_selectors.rb:12:in `set_selectors'
app/controllers/test.rb:15:in `block (2 levels) in <module:Test>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant