NameError: uninitialized constant Rpush :: Gcm I'm trying to use rpush for my mobile application. But I keep getting this error

So, I tried to use rpush for push notifications of my mobile application using this stone: https://github.com/rpush/rpush . I use the sinatra structure. But I keep getting this error, although I wrote -> requires "rpush" at the top of my file. Can any of the rubies help me? I am new to ruby, so please carry me. Here is my code

require 'rpush' Module Notifier def rpush_client app = Rpush::Gcm::App.new app.name = "App-Name" app.auth_key = "XXXXXXXXXXXXXXX" app.connections = 1 app.save! end def notify(user_id,alert) rpush_client session = db_find_one('dbname.sessions',{user_id: user_id}) if session.present? device = session['devices'].first token = device['device_token'] n = Rpush::Gcm::Notification.new n.app = Rpush::Gcm::App.find_by_name("App-Name") n.registration_ids = ["token", token] n.data = { message: alert } n.save! Rpush.push end end end 

I know his stupid question, but I'm tired of looking for him here.

+5
source share
1 answer

Do you use a bunch with Sinatra? If so, you do not need to explicitly require Rpush. See here: http://bundler.io/sinatra.html

0
source

Source: https://habr.com/ru/post/1209334/


All Articles