RoR iOS Push Notifications with Grocer Gem
I'm very new to RoR and web servers in general. Basically I want to create a web service to run push notifications for my iOS app.
I'm trying to use the Grocer Gem and so far i can get it working if i put the functions in the rakefile in my RoR project... but that doesn't seem like the right way to do it.
1) Where should I put those functions.
2) How do I make those functions run when the server starts.
All files in the config/initializers folder are auto-loaded when the app starts. You can put all the Connecting section's codes in there. You should change pusher to a global variable so it's accessible outside the file:
$pusher = Grocer.pusher(...) # instead of: # pusher = Grocer.pusher(...)
The code in the Sending Notifications code can be called anywhere. Just make sure you use the global variable when you call $pusher.push(notification).
By the way, the Rakefile is used for 'tasks' which are not meant to be called in your app. For example, commands you call manually in your shell like rake db:migrate and rake assets:precompile. So unless you're making one of these, there's no reason to edit that file.