-
Notifications
You must be signed in to change notification settings - Fork 53
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
NoMethodError (undefined method `post' for nil:NilClass) #15
Comments
Can you provide a backtrace please? |
Hi Andreas We found the reason of the problem, and why it worked in testing but not in production. We are doing the API setup in a initializers/podio.rb file, with Podio.setup(:api_key => 'YOUR_API_KEY', :api_secret => 'YOUR_API_SECRET') Now, the problem is that in production we use Passenger (with Apache), and we discovered that the setup is only done once when starting the server - not once for every process that Passenger spawns. And your client is somehow tied to the process itself, so, inside each passenger processes, Podio.client is actually nil We did a quick fix by adding a before_filter to ApplicationController, and init the api if Podio.client.nil? , but this is very ugly. If you are aware of - or can find - any better solution to init the API only once, in a way that works with Passenger (which I think is used by 99% of Rails developers), that would be very useful :) |
The gem uses thread local storage to store the current connection, which I think is causing what you're experiencing. This is mentioned briefly in the readme, but should probably be more explicit. We'll try think of a better solution -- thanks for bringing up the issue! |
Ok, please update us if you find one! |
Just ran into this issue as well. Thanks for the workaround @danmaz74 |
Having the same issue when calling Podio in Sidekiq job. What's the best way to initialise library when using Sidekiq? |
I haven't personally used Sidekiq but I did a quick scan of the docs. There is a mention that workers must be thread safe. It appears that you'd have to initialize a connection to the Podio Api within each worker. |
Hello,
"NoMethodError (undefined method `post' for nil:NilClass)" shows only in production when the app executes Podio::Item.create, Podio::Search.in_app, etc. I tried to execute the same thing in the production console but it works. Same goes under development environment - the app works fine. My current setup below:
config/initializers/podio.rb
require 'rubygems'
require 'podio'
Podio.setup(:api_key => 'YOUR_API_KEY', :api_secret => 'YOUR_API_SECRET')
Podio.client.authenticate_with_credentials('YOUR_PODIO_ACCOUNT', 'YOUR_PODIO_PASSWORD')
Thanks,
Henry
The text was updated successfully, but these errors were encountered: