Heroku deployment using Mongo - ruby-on-rails

Can someone tell me what I am doing wrong? I am trying to push a simple rails app to Heroku that uses MongoDB. My Gemfile contains the following line:
gem "mongo"
When pushing the app to Heroku it error's out with: no such file to load -- mongo
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler version 1.0.3
Unresolved dependencies detected; Installing...
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- mongo (LoadError)
Here is my whole gemfile:
require 'rubygems'
require 'mongo'
source 'http://gemcutter.org'
gem "rails", "3.0.0"
#gem 'rails', :git => 'http://github.com/rails/rails.git'
gem "mongo_mapper"
gem 'mongoid', '2.0.0.beta.20'
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem 'heroku', '1.13.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

You dont need either of these lines in your Gemfile:
require 'rubygems'
require 'mongo'
Neither of those are required for bundler to update or install your gems.
Also, is there a reason why you're installing both mongoid and mongo_mapper?

Perhaps another approach that you can use, is to use something like https://mongolab.com, connect you application with the database on the cloud, and then make the deployment (only the rails application).I've been using MongoLabs for a while, and works pretty good, you can check your collections directly from there (you don't need to use the JS shell). This is just a suggestion, to make the deployment easier :)

Related

Rails doesn't load actionform gem from Gemfile

My Rails 4.2 app fails to load some GitHub hosted gem (installed via bundler v1.8.2). I am using rvm 1.26.10 (master)
In my Gemfile,
gem 'simple_form', '~> 3.1.0'
gem 'actionform', :github => 'rails/actionform'
Bundler install them in different location:
$ bundle show simple_form
/Users/me/.rvm/gems/ruby-2.1.5#my_app/gems/simple_form-3.1.0
$ bundle show actionform
/Users/me/.rvm/gems/ruby-2.1.5#my_app/bundler/gems/actionform-4a858fecf4c2
Rails never load the actionform gem.
After inserting the line //= require action_form to my app/assets/javascript/application.js file, this error comes
Sprockets::FileNotFound at / couldn't find file 'action_form'
However, the action_form.js file exists in the gem file.
Moreover, when i try to reproduce the readme example, i got this error
NameError at /conferences/new uninitialized constant ActionForm
require 'bundler/setup' is in boot.rb
Any advise about this issue?
Thanks!
The problem is a mismatch between the gem name and the file inside the gem. Because the gem is named 'actionform', Bundler will try to require 'actionform', however the file is actually called action_form.
You can tell Bundler the right file name with this syntax:
gem 'actionform', :github => 'rails/actionform', :require => 'action_form'
Note that it is normal for gems from git sources to be installed into a different location than gems installed from gem servers. It has nothing to do with this problem.

Gem is not available after bundle install

I have a Gemfile where I add a new gem
gem 'activerecord-oracle_enhanced-adapter', git: "https://github.com/rsim/oracle-enhanced.git", branch: "rails4"
When I run bundle install I get
> bundle install
Updating https://github.com/rsim/oracle-enhanced.git
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
...
Using activerecord (4.0.0)
Using activerecord-oracle_enhanced-adapter (1.4.2) from https://github.com/rsim/oracle-enhanced.git (at rails4)
Using bundler (1.3.5)
...
But when I call gem list, the gem is missing. If I try to load this gem in the irb, I get
irb
require 'rubygems'
=> false
gem 'activerecord'
=> true
gem 'activerecord-oracle_enhanced-adapter'
Gem::LoadError: Could not find 'activerecord-oracle_enhanced-adapter' (>= 0) among 49 total gem(s)
I do not understand this behavior. I have several gems added to my Gemfile this way and all of them are working.
My system for the test:
RVM
ruby 2.0.0p195
new gemset
new rails 4 project without any modification except this gem in the Gemfile
I tried it with two different users
Ubuntu 12.04
If I call gem install activerecord-oracle_enhanced-adapter, this gem is installed, but not from the 'rails4' branch and I would like to use the Gemfile
Try calling bundle exec irb so you will load irb in specific Gemset scope instead of system one.

Rails 3.0 - can't load ruby-oci8 with Bundler

Rails n00b here - need some assistance. I am trying to port a Rails3 app from Linux to Windows. My Gemfile looks as follows:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'ruby-oci8', '1.0.6'
I do not have an Oracle client on this Windows machine, so I will not be able to natively compile a ruby-oci8 gem.
I have commented out the 'ruby-oci8' line in my Gemfile and I installed the gem manually from here: http://rubygems.org/downloads/ruby-oci8-1.0.6-x86-mswin32-60.gem. I have also copied the necessary DLLs into ruby\bin.
I have verified that it works:
ruby -rubygems -e "require 'oci8'; OCI8.new('user','password','pasdev:2700/gen11dvu').exec('select * from ARCS_USER_LO
GON') do |r| puts r.join(','); end"
This returns lots of data from my db, so I know it works.
However, if I try to require 'oci8' from a rails console (or from the running app), I get the following:
LoadError: no such file to load -- oci8
I presume this happens b/c Rails only loads the gems specified in the Gemfile, but I cannot figure out how to specify it! I already have the gem I need installed:
C:\javadev\ashbtw3>gem list
*** LOCAL GEMS ***
activerecord (3.0.0)
bundler (1.0.21, 1.0.0)
rails (3.0.0)
rake (0.8.7)
ruby-oci8 (1.0.6 x86-mswin32-60)
...etc...
Yet if I uncomment this line in the Gemfile:
gem 'ruby-oci8', '1.0.6'
bundler tries to download and compile another 1.0.6, which of course fails. I have also tried all of these variations unsuccessfully:
gem 'ruby-oci8', '1.0.6', :platforms => :mingw
gem 'ruby-oci8', '1.0.6-x86-mswin32-60', :platforms => :mingw32
gem 'ruby-oci8-1.0.6-x86-mswin32-60'
gem 'ruby-oci8', '1.0.6-x86-mswin32-60'
Why is bundler trying to install a gem that I already have? How do I properly specify the version and platform to make Bundler see that this gem is already installed, and just include it in Gemfile.lock? Is there some other solution here that I can use w/o installing an Oracle client?
EDIT 1:
As per Kyle's suggestion, I tried the following:
gem 'ruby-oci8', :path => 'C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
This made Bundler run successfully!
Using ruby-oci8 (1.0.6) from source at C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
However, trying to require 'oci8' from the Rails console now gives me this:
C:\javadev\ashbtw3>ruby script\rails console
Loading development environment (Rails 3.0.0)
irb(main):001:0> require 'oci8'
LoadError: no such file to load -- oci8lib
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60/lib/oci8.rb:20
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
The file it's missing is in under ext/oci8 in the installed gem directory, yet it does not see it.
Is there something additional I can do?
Have you tried specifying the :path ?
gem 'ruby-oci8', :path => '/path/to/ruby-oci8-1.0.6-x86-mswin32-60'

Heroku's trying to install development gems even after I've told it not to

I'm diving into RoR and I'm using Heroku to host the test app I'm building. When I do a push to Heroku, it crashes when trying to intall the linecache19 gem (which is used by ruby-debug19 gem)...
Installing ruby_core_source (0.1.4)
Installing linecache19 (0.5.11) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
After searching all over the web for this problem, everyone's solution was...
heroku config: add BUNDLE_WITHOUT="test development" --app app_name
But the push to Heroku still crashes even after I did that. Here's my Gemfile...
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem "carrierwave"
gem "mini_magick"
gem "fog"
group :development do
gem 'annotate-models', '1.0.4'
gem 'sqlite3'
gem 'ruby-debug19'
gem 'sqlite3-ruby', :require => 'sqlite3'
end
I even uninstalled the ruby-debug19 gem and it's still crashing and trying to install the linecache19 gem. Why won't this linecache19 gem go away? I'm new to all this and, as such, I'm sure I'm missing something obvious. Your thoughts?
Thanks for your wisdom!
Your heroku config command is malformed. You have a space before add and you are missing the colon between development and test.
$ heroku config:add BUNDLE_WITHOUT="development:test" --app app_name
Docs are here.
Also, are you remembering to run bundle install locally and commit both your Gemfile and Gemfile.lock into git?

Pushing rails app to heroku not working

I'm trying to use git push heroku master to upload my rails 3 app to heroku, but I keep getting the following error:
-----> Heroku receiving push
-----> Removing .DS_Store files
-----> Rails app detected
! Heroku Bamboo does not include any Rails gems by default.
! You'll need to declare it in either .gems or Gemfile.
! See http://docs.heroku.com/gems for details on specifying gems.
! Heroku push rejected, no Rails gem specified.
error: hooks/pre-receive exited with error code 1
I've tried deleting the on the heroku website and starting again, i've also tried wiping out my git repo and doing init again, and I keep getting the same error. My Gemfile is as follows:
source :rubygems
gem 'rails', '3.0.3'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'devise', '1.1.3'
gem 'acts-as-taggable-on'
gem 'ruby-debug'
# for sass
gem 'haml'
gem 'mocha'
gem 'ruby-pg'
I've run bundle package to package teh gems into vendor cache, but it doesn't seem to change the result.
I upgraded this app from rails 2.3, so i'm wondering if that has anything to do with it?
This is the answer I got from Heroku:
Hi,
The problem seems to be that your Gemfile is called GemFile. While that'll work on some platforms like the Mac, that won't work on a strictly case-sensitive filesystem, such as ours.
In order to rename the file in a case-retaining, case-insensitive file system like HFS or NTFS, you'll need to do it in two steps:
git mv GemFile Gemfile.temp
git mv Gemfile.temp Gemfile
Try adding these to your Gemfile
gem 'pg' # Heroku's DB runs on postgresql
gem 'heroku'

Resources