Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

undefined method `macro' for nil:NilClass #154

Closed haslinger closed 9 years ago

haslinger commented 9 years ago

I have a strange issue after deploying, I get the error

/home/rails/.rvm/gems/ruby-2.1.5/bundler/gems/hobo-2021b4e8cf3c/hobo/lib/hobo/controller/model.rb:272:in
 `auto_actions_for': undefined method `macro' for nil:NilClass (NoMethodError)

when I try to migrate the database, compile the assets or run the console. It results from my auto_actions_for :user, :index in the orders_controller, Orders have a belongs_to relation to User, so nothing too fancy.

So I looked into the line, which is the second line of the method definition:

      def auto_actions_for(owner, actions)
        name = model.reflections[owner].macro == :has_many ? owner.to_s.singularize : owner

in another system, everything is fine: Order.reflections[:user].macro returns :belongs_to

Currently, I'm mainly thinking, how I can debug this ...

haslinger commented 9 years ago

Well this was an interesting one. When I commented out the author actions, the original error showed up. I unintentionally imported an extension for the Order model from an Engine, that was not installed - so the import failed. Removing that import let the application start again. Then I commented in the auto_actions again and everything was find. My learnings: Errors can be shadowed ....

iox commented 9 years ago

Interesting!