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.

The two functions I'm using are Connecting and Sending Notifications

1) Where should I put those functions.

2) How do I make those functions run when the server starts.

Answers


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.


Need Your Help

EGit : How to prevent fast-forward merge?

eclipse git merge egit

The company I work for gave me the project of moving their java project from CVS to Git. For several reasons, they don't want to use another tool than Eclipse. So we're stuck with EGit.

Joomla Module Chrome module index

php html css joomla

I am using Joomla Module Chrome to style a sidebar. Is it possible to find out if the current module is the last module in the modules.php file?