Problem with API

catwood's Avatar


10 Jul, 2007 07:55 PM

I've run into a strange problem with the lighthouse.rb file in my rails app.

From the ./script/console I can run:

ticket = => 2991)

and I get back a blank ticket. But from my local defect controller when I run the same line:

ticket = => 2991)

I get this error:

NoMethodError (You have a nil object when you didn't expect it! The error occurred while evaluating nil.path):

/vendor/rails/activeresource/lib/active_resource/base.rb:196:in `prefix'
/vendor/rails/activeresource/lib/active_resource/base.rb:206:in `prefix_source'
/vendor/rails/activeresource/lib/active_resource/base.rb:460:in `prefix_parameters'
/vendor/rails/activeresource/lib/active_resource/base.rb:475:in `split_options'
/vendor/rails/activeresource/lib/active_resource/base.rb:473:in `each'
/vendor/rails/activeresource/lib/active_resource/base.rb:473:in `split_options'
/vendor/rails/activeresource/lib/active_resource/base.rb:829:in `send'
/vendor/rails/activeresource/lib/active_resource/base.rb:829:in `split_options'
/vendor/rails/activeresource/lib/active_resource/base.rb:724:in `load'
/vendor/rails/activeresource/lib/active_resource/base.rb:499:in `initialize'
/app/controllers/defects_controller.rb:11:in `new'

The issue seems to be that the "site" parameter isn't being set and it nil. What I don't understand at all is that it works from ./scipt/console, but not the app controller.

Any ideas?

  1. 1 Posted by Rick on 11 Jul, 2007 01:07 AM

    Rick's Avatar

    You set Lighthouse.account, right? That's a shortcut that sets the site value on all of the Lighthouse ActiveResource classes.

  2. 2 Posted by catwood on 11 Jul, 2007 02:02 AM

    catwood's Avatar

    Yep, Lighthouse.account is set in environment.rb

    If I comment the line out, I get the same nil.path error, but it occurs during ./script/console initialization and I can't even test the call.

  3. 3 Posted by catwood on 11 Jul, 2007 02:15 AM

    catwood's Avatar

    Well I just found a work around - I don't understand why it works, but it does

    In environment.rb I added:

    @@tickets = Lighthouse::Ticket

    and now this line works without the nil.path error:

    ticket = => 2991)

    My guess is that the Controller extending ActionController::Base causes some variable overwrite problem, which the @@ hack above bypasses. But that is just speculation - I'm too new to rails to understand its inner workings.

Discussions are closed to public comments.
If you need help with Lighthouse please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac