-
Notifications
You must be signed in to change notification settings - Fork 156
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
uninitialized constant APN::App::RAILS_ENV #53
Comments
Are you using bundler? Are you running it as bundle exec rake? Andrew Kuklewicz On Tue, Jul 17, 2012 at 5:11 PM, Billy Coover <
|
Yes I'm using bundler. I've tried running the following:
Both fail with the same error. |
I'm having the exact same issue and getting uninitialized constant APN::App::RAILS_ENV, I just started working on this today. Mine is a Rails 3.2 app, I'm simply adding gem 'apn_on_rails' to my gem file and normal bundle install. If I do not use an APN::App model and rely on the configatron, I get the following error: No such file or directory - /config/apple_push_notification_development.pem. Configatron config is verbatim from the readme: configatron.apn.cert #=> File.join(RAILS_ROOT, 'config', 'apple_push_notification_development.pem') I'm having the feeling that maybe I'm not pulling from the correct repository and will investigate that next. |
Oh well, I'm able to work around this by hardcoding the full path in app/models/apn/app.rb, line 35 of def self.send_notifications where it is assigning global_cert. I can now continue my testing but will be interested in the real solution so I can unpatch my code. |
oh... to help azcoov, in order for my hack to work I first had to put the following line at the top of configatron/development.rb: RAILS_ROOT, APN::App::RAILS_ENV='development' I found this in another open issue on this site. |
Thanks Gary! I'll give this a whirl. // Billy On Wednesday, July 18, 2012 at 7:14 AM, garyfoster wrote:
|
@garyfoster What's that hard-coded path look like for you after the change?
|
global_cert = File.read("/Users/garyfoster/Documents/Projects/ruac/config/apple_push_notification_development.pem") I've since found that my configatron settings are not being read so it's falling back to the defaults. I'm sure I can figure this out properly but i've got my head in my ios client side code and need to focus on that so I'm only giving it a half-ass effort. |
I just ran into this issue too. My Rails knowledge is not very deep, but it seems like the problem is deprecation of RAILS_* environment variables. I user Rails 3.1.0 and I do NOT have RAILS_ROOT/ENV/blah there. Instead, I have Rails.root/env/blah. When I replace RAILS_ENV with Rails.env in app/models/apn/app.rb the first problem goes away. Then I get the second error: "No such file or directory - /config/apple_push_notification_development.pem", which could be because ROOT_ENV is non-existant. (Although I don't have ANY configatron stuff in my config files - not sure whether that's an issue if I store the certs in the DB). So, the bottom line is, is this gem compatible with Rails 3.1.0??? It seems not. Is there a workaround that wil allow its use in a Production environment? Maybe similar to one of the above suggestions: define somewhere APN::App::RAILS_ENV = Rails.env. But where? |
I lost interest in this problem when I realized I do not need this functionality to go live unless I use the supplied rake task. Here is what I did to proceed:
For #2, I ended up creating my own rake task since I needed it to do some other things as well. The task get's the appropriate APN::App and executes it's send_notifications method. If you have just one app, you could do something like the following: app = APN::App.first |
@garyfoster Thanks for the tips! I actually did get this to work yesterday by doing the same: add the certs to the APN::App table and create my own rake task that uses APN::App.send_notifications directly. :) HOWEVER, that method still calls APN::App.cert, which does '(RAILS_ENV == 'production' ? apn_prod_cert : apn_dev_cert)'. I had to put 'APN::App::RAILS_ENV = Rails.env' at the top of my config/environment.rb file. Did you have to do anything similar to bypass the deprecated env variable? |
ah, yes, I did that same thing as well, had forgotten |
Yeah !! I can push notification.
eg. in file configatron/devlopment.rb
I run "rails c" for create App, Device and Notification eg.
eg.
eg.
I create my task in lib/tasks so i create file apn_on_rails.rake eg.
so in rails console >> rake deliver_notifications It work for me. I can deploy on Heroku |
Hi there, Rails noob here and I'm struggling trying to figure out how to solve this error. It's barking about the RAILS_ENV variable. I've tried a couple of forks that change this to Rails.env but I still get the same error. I don't know enough about rails to dig in any further and I was hoping you could point me in the right direction.
The text was updated successfully, but these errors were encountered: