NameError:未初始化的常量Rpush :: Gcm我正在尝试将rpush用于我的移动应用程序.但我一直收到这个错误

Ren*_*ade 6 gem notifications android push sinatra

所以我试图使用rpush来使用这个gem的移动应用程序的推送通知:https://github.com/rpush/rpush.我正在使用sinatra框架.但我一直得到这个错误,即使我在我的文件顶部写了 - > require'rpush'.有人在红宝石中有经验可以帮助我吗?我是红宝石的新手所以请耐心等待.这是我的代码

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
Run Code Online (Sandbox Code Playgroud)

我知道这是一个愚蠢的问题,但厌倦了在这里寻找它.

ile*_*tch 0

您是否将捆绑器与 Sinatra 一起使用?如果是这样,您不需要明确要求 Rpush。请参阅此处: http: //bundler.io/sinatra.html