Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9012171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:55:42+00:00 2026-06-16T02:55:42+00:00

I am new to Ruby, Sinatra and Pusher so this is a basic question.

  • 0

I am new to Ruby, Sinatra and Pusher so this is a basic question. I am attempting to authenticate a Pusher Client (using iOS demo code https://github.com/lukeredpath/libPusher). The server code below fails with error when the iOS client attempts to join a presence channel:

ArgumentError - wrong number of arguments (1 for 2):
    /Users/waveocean/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:665:in `render'
    web.rb:13:in `auth'
    web.rb:26:in `block in <main>'
    /Users/waveocean/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call'

... snipped for brevity ...

Here is the code:

require 'sinatra'
require 'pusher'
require 'thin'
Thin::HTTP_STATUS_CODES[403] = "FORBIDDEN"

Pusher.app_id = 'MY-APP-ID'
Pusher.key = 'MY-KEY'
Pusher.secret = 'MY-SECRET'

def auth
  response = Pusher[params[:channel_name]].authenticate(params[:socket_id], {:user_id => 101})
  render :json => response
end

 use Rack::Auth::Basic, "Protected Area" do |username, password|
   username == 'foo' && password == 'bar'
 end

 post '/presence/auth' do
   if params[:channel_name] == 'presence-demo'
      auth
   else
   #   render :text => "Forbidden", :status => '403'
   response.status = 403
   end
 end

Can someone provide a suggestion or correct usage of render?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:55:44+00:00Added an answer on June 16, 2026 at 2:55 am

    Here’s is what I discovered. render is associated with Rails, and not strictly Ruby. To respond to the Sinatra route, use the following in the auth method:

    def auth
      response = Pusher[params[:channel_name]].authenticate(params[:socket_id], {:user_id => 101})
      [200, {"Content-Type" => "application/json"}, response.to_json]
    end
    

    As it turns out, the Pusher iOS project demo provides a Scripts/auth_server.rb file with the required implementation. It is documented with the installation instructions here: https://github.com/lukeredpath/libPusher/wiki/Adding-libPusher-to-your-project .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to ruby & Sinatra and I have a basic question: The
I'm new to this, and I'm using datamapper and sinatra to build a basic
I'm very new to Ruby and using Sinatra, mainly so that I can do
I'm new to ruby, sinatra and padrino, so it might be a silly question,
I’m relatively new to Ruby, Sinatra, and DataMapper, but have a question about DataMapper
Im new to ruby, wrote this code and works but i know is not
I don't know if this is a ruby question or a Sinatra question, because
Edit: I'm using Ruby with Sinatra. UPDATE: here is the code I'm using which
I'm using resque-status for Resque/Redis... https://github.com/quirkey/resque-status I basically want to create a new Sinatra
I want to show flash messages using sinatra-redirect-with-flash gem. Here's my ruby code: require

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.