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 6354837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:38:43+00:00 2026-05-24T22:38:43+00:00

I have the apn_for_rails gem installed and configured correctly, the problem I’m running into

  • 0

I have the apn_for_rails gem installed and configured correctly, the problem I’m running into is probably a syntax problem due to my newness to Ruby on Rails.

I have this in /models under the file push_notification.rb

class ApnDevice < ActiveRecord::Base

end

in routes.rb

match '/api/v2.0/RegisterIOSDevice',              :to => Api::V_2_0::ApiNotifications

and then I have another file in /lib/api/v_2_0 called api_notifications.rb

require 'rubygems'
require 'sinatra/base'
require 'nokogiri'
require 'apn_on_rails'

module Api
  module V_2_0
    class ApiPushNotification < sinatra::Base
      include ApplicationHelper
      include Api::V_2_0::ApiResponse
      include ApiUtil

      def push_notification(params)
        status = -1
        error = nil
        begin
          if params[:device_token].blank?
            return status_respnse(params,status,'device_token cant be blank')
          end
          existing_device_token = ApnDevice.find_by_token(params[:device_token])
          if existing_device_token
            return status_response(params,status,'Token already exists for device')
          end
          token = ApnDevice.create!(:token => params[:device_token])
        rescue Exception => e
          error = e.message
          Rails.logger.info "#{e.class} : #{e.message}"
          Rails.logger.info e.backtrace.join("\n")
        rescue => e
          error = e 
          Rails.logger.info "Caught exception: #{e}"
          Rails.logger.info e.backtrace.join("\n")
        end #end of rescue
        status_response(params,status,error)
      end
      get '/api/v2.0/RegisterIOSDevice.:format' do
        push_notification(params)
      end
      post '/api/v2.0/RegisterIosDevice.:format' do
        push_notification(params)
      end
    end #end of class ApiPushNotification
  end #end of module V_2_0
end #end of module Api

but it gives me this huge error when I run my server, I won’t post the whole thing, but it says this basically

/lib/api/v_2_0/api_notifications.rb:7: invalid multibyte char (US-ASCII) (SyntaxError)
/lib/api/v_2_0/api_notifications.rb:7: syntax error, unexpected $end, expecting keyword_end

this is followed by a stack trace which I will not post but I can’t seem to find the problem, any ideas?

Edit:

ok I added the utf-8 suggestion, now I’m getting a new error:

lib/api/v_2_0/api_notifications.rb:46: syntax error, unexpected keyword_end, expecting $end (SyntaxError)
  • 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-05-24T22:38:43+00:00Added an answer on May 24, 2026 at 10:38 pm

    I don’t know what you are doing there, but why are you using Rails if you use Sinatra instead in lib?

    To your error, add the following code at the first line:

    # encoding: utf-8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a group of related projects running in SQL Server 2005 for which I
Have just started to get into CakePHP since a couple of weeks back. I
I'm trying to split json data I have in a NSDictonary into smaller parts
Have just started converting an existing job tracking system into an ASP.NET MVC application.
Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have someone tried out DeCAL in Delphi 2009? I'm thinking about upgrading from 2007,
Have a matrix report now that has Position, Hours and Wages for a location
Have you ever obfuscated your code before? Are there ever legitimate reasons to do
Have you ever created or encountered a self modifying code in Java? If yes,

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.