uninitialized constant APN::Device (apn_on_rails for rails3 ) - ruby-on-rails-3

I have followed this tutorial to configure apn_on_rails but I am getting the following error message when I call my action:
uninitialized constant APN::Device
This is the line that produces the conflict:
device = APN::Device.create(:token => device_token)
As suggested here, I have added a require 'apn_on_rails' in my environment.rb but nothing changed.
It seems that the gem apn_on_rails is only installed under gem/bundler, could that be the problem? If so, how can I install it if I have it in my gemfile like this:
gem 'apn_on_rails', :git => 'https://github.com/natescherer/apn_on_rails.git', :branch => 'rails3'
then how can I call something like sudo gem install 'apn_on_rails' ... to install that version?
I am using ruby 1.9.2 and rails 3.1.
Any help is greatly appreciated.

I fixed by following these instructions and making a change to that solution
Clone the Git repository.
$ git clone https://github.com/natescherer/apn_on_rails.git
Change to the new directory.
cd apn_on_rails
Build the gem.
$ gem build apn_on_rails.gemspec
(Running that I got:
Successfully built RubyGem
Name: apn_on_rails
Version: 0.3.1rails3
File: apn_on_rails-0.3.1rails3.gem
Install the gem.
$ gem install apn_on_rails-0.3.1rails3.gem

Related

Rails can't install gem sqlite

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.0' succeeds before bundling.
I tried to install earlier version on sqlite, not working.
Tried one of the solutions from stackoverflow :
gem 'sqlite3', '~> 1.3.6'
getting this error
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sqlite3,
Please help i'm new in Rails , this is my first project in rails.
Add gem 'sqlite3' to Gemfile in the root directory of your rails project. Then run bundle install and it should install sqlite and make it available to use in your rails project.
Specify git and branch for the gem sqlite3 in your Gemfile should fix the problem.
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
For more info
https://medium.com/#declancronje/installing-and-troubleshooting-ruby-on-rails-sqlite3-windows-10-fix-87c8886d03b
cannot load such file — sqlite3/sqlite3_native (LoadError) Ruby on Rails
Replace gem 'sqlite3' with gem 'sqlite3', '~> 1.3.11' which is in Gemfile in the root directory of your rails project. Then run bundle install.

Bundler::GemRequireError when adding gem

When I make a new Rails project, add gem 'reactive-record', and run rails server, I get a Bundler error: There was an error while trying to load the gem 'reactive-record'. (Bundler::GemRequireError).
What gives? I have Rails 4.2.5 and Ruby 2.1.2.
Cheers!
The latest version of the generator should work very well with the help of Mitch. We collaborated together to make a generator in order to simplify greatly the installation of react.rb and reactive-record.
You should be able to get up and running by adding to your gem file :
gem 'reactive_rails_generator'
Then do a bundle install
and finally :
rails g reactrb:install --all
bundle update
Will install you reactrb, reactive-record and reactive-router.
Once installed, you can create components by doing :
rails g reactrb:component Home::Show
I worked around the problem like this:
Set rvm to use Ruby 2.2.2 and Rails 4.2.4.
Download https://codeload.github.com/catprintlabs/reactive-record/zip/master
Edited reactive-record-master/Gemfile to read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
cd reactive-record-master/spec/test_app
bundle install
rails server
This seemed to work.
Then, I made a new Rails 4.2.4 project. Adding only gem 'reactive-record' to the Gemfile resulted in the same error. Then I made the Gemfile read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
gem 'reactive-record'
And voila, rails server works!
Hope this helps someone else.

ruby_threadptr_data_type error

I'm starting up a new rails app with the latest version of rails (3.1.3). Rails crashes when I try to start up the server. First I fixed this bug, and now I'm getting this one
ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type
There's a discussion about this going on here, but I can't make enough sense of it to get things to work.
UPDATE
I updated the version of ruby-debug
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
and have now moved on to this error
linecache19-0.5.12/lib/trace_nums19.so: undefined symbol: ruby_current_thread
Ok, it turns out that both ruby-debug and linecache needed to be manually updated to the latest versions. These lines in my gemfile did the trick
gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
gem 'ruby-debug19'
To run specs, you need to run bundle exec rspec -d spec
At last I found the problem. The debugger in RubyMine starts without bundle exec, so it doesn't use linecache19 from git. You need to install it manually.
Resolution of the problem found here: http://youtrack.jetbrains.com/issue/RUBY-9418?projectKey=RUBY
gem uninstall linecache19
gem uninstall ruby-debug-base19x
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem install linecache19-0.5.13.gem
gem install ruby-debug-base19x –-pre
Make sure to uninstall all linecache19 and ruby-debug-base19x!
The following lines worked for me:
gem 'linecache19'
gem 'ruby-debug-base19x'
gem 'ruby-debug19', :require => 'ruby-debug'
(Hat tip to declan. His comment didn't work for me, but it gave me the idea to add linecache19.)
after trying all advise on stackoverflow, the following combination worked for me
gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
gem 'ruby-debug19'
I'm running Rails 3.1.3 on Ruby 1.9.3-p0 with RVM
when I set :require => 'ruby-debug' the server would not start.
It's repost from this
I also ran into this, and found the solution in Ruby 1.9.3 and ruby-debug. You need to install not-yet-officially-released versions of ruby-debug-base19 and linecache19. The currently released versions indeed cause the exception you had.
Use this gist.
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
# Note, your source path should be something like /home/user/.rvm/src/ruby-1.9.3-p0
gem install archive-tar-minitar
gem install ruby_core_source-0.1.5.gem -- --with-ruby-include=/$RVM_SRC
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug19-0.11.6.gem -- --with-ruby-include=/$RVM_SRC
I tried it and it's work!
This is solve of our problems.

How to install gem/plugin in rails3 when not found on rubygems?

I want to install the simple-private-messages gem (http://agilewebdevelopment.com/plugins/simple_private_messaging), https://github.com/jongilbraith/simple-private-messages.
I added to my Gemfile:
gem 'simple-private-messages'
But get error:
Fetching source index for http://rubygems.org/
Could not find gem 'simple-private-messages (>= 0)' in any of the gem sources listed in your Gemfile.
I then tried modifying Gemfile to:
gem 'simple-private-messages', :git => 'git://github.com/professionalnerd/simple-private-messages.git'
but get error:
Fetching git://github.com/professionalnerd/simple-private-messages.git
github.com[0: 207.97.227.239]: errno=Operation timed out
fatal: unable to connect a socket (Operation timed out)
Git error: command `git clone 'git://github.com/professionalnerd/simple-private- messages.git' "/Users/homanchou/.rvm/gems/ruby-1.9.2-p180/cache/bundler/git/simple-private-messages-26451211e7d7acc0c1b523bad2621cb2cd38f77e" --bare --no-hardlinks`
1) How else can I install this gem locally?
2) How can I deploy this app to heroku and protect against deployment error if Heroku can not find the gem in any repositories? Do I vendor them into the app?
It doesn't look like that project is a Gem; it's actually a Rails Plugin.
To install, run this in your project folder:
rails plugin install git://github.com/jongilbraith/simple-private-messages.git

thoughtbot / paperclip Gem installation

Im not going to start by saying i'm a newbie etc. Jokes, been learning Rails for nearly month using Lynda.com. I use Mac, Mac OS X Lion 10.7.
I am trying to intall Paperclip Gem but i can't seem to figure out what i'm doing wrong.
I followed the instructions on https://github.com/thoughtbot/paperclip/wiki/Installation
I added this line to my config/environment.rb
config.gem 'paperclip', :source => 'http://rubygems.org'
and i then tried to run
rake gems:install
I get an error message:
(in /Users/fred/Ruby/food)
rake aborted!
undefined local variable or method `config' for main:Object
/Users/fred/Ruby/food/Rakefile:4:in `require'
(See full trace by running task with --trace)
I then tried the following as an alternative when the above failed
script/plugin install git://github.com/thoughtbot/paperclip
I get the following error
-bash: script/plugin: No such file or directory
My question is how do install this gem? I have read a lot of other posts that say i should include gem 'paperclip', "~> 2.3" is this the same as what i did above?
Best to use bundler. Steps are
Install bundler: gem install bundler
Add to Gemfile: config.gem 'paperclip'
cd to where the Gemfile is and run: bundle install. This will install all the gems mentioned in the Gemfile
Ps. I assume that you are not using rvm. Also, you may need to prefix sudo to the command in step 1 above in case the command does not work for you due to a permission problem.