I can't migrate the database of my Rails app on Heroku with sqlite - ruby-on-rails-3

I'm following this tutorial on creating Ruby on Rail apps, and I've hit a roadblock. I am trying to migrate its database to Heroku, only to be told this:
c:\Sites\railsbridge\test_app>heroku run rails db:migrate
Running rails db:migrate on floating-ocean-40882... up, run.5709 (Free)
rails aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not
loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the
minimum required by ActiveRecord).
I already have sqlite3 listed in my Gemfile, what am I doing wrong?

Heroku does not support sqlite and it is suggested to use postgresql for production
Please look into the following posts
Heroku deployment failed because of sqlite3 gem error
Deploying RoR app to Heroku with Sqlite3 fails
You can use Postgresql for production and the change should be simple. Just a change of gem in Gemfile and change in database.yml will do.

Heroku doesn't support SQLite it only support PostgresSQL here is full documentation for deployment on Heroku

Related

How to convert rails 4 app's database from sqlite3 to postgresql?

I have tried multiple ways to convert my existing rails app's database from sqlite3 to postgresql. i tried converting my database.yml file's adapter to postgresql and running rake db:create and migrate but that did not work i tried adding gem 'pg' instead of sqlite3 but still does not work. I am not able to push my projects to heroku i always get an "application error" when i run my heroku web site.
Make sure that you have removed sqlite3 from your Gemfile, and run bundle.
You may need to do a heroku migration.
heroku run rake db:migrate

Advantage of "bundle exec rails server" over a simple "rails server"?

I bought Crafting Rails Applications this weekend and noticed that the author uses
bundle exec rails server
to start the development server. What's the advantage of using this command over a simple "rails server"? Is it simply to keep gem dependencies under control?
bundle exec runs the server in the context of the bundle that you have installed...
rails s or rails server does almost the same.
But if you are using rvm or something else you might have some special bundles with special versions of the gems.

Error using mongrel 1.2.0.pre2 in rails 3 app on heroku

I am doing authentication from google and was getting request too long error so upon some research I added the mongrel gem. This fixed the request too long error on my local machine.
However, now when I push to heroku, I constantly get the error below
You have already activated daemons 1.1.0, but your Gemfile requires
daemons 1.0.10. Consider using bundle exec. (Gem::LoadError)
Gemfile:
gem 'pg'
gem 'compass', '>= 0.11.5'
gem 'fancy-buttons'
gem 'haml', '3.1'
gem "nifty-generators", :group=>:development
gem "bcrypt-ruby", :require => "bcrypt"
gem "jquery-rails"
gem "devise"
gem "omniauth"
gem 'oa-openid', :require => 'omniauth/openid'
gem 'mongrel', '1.2.0.pre2'
Perhaps taking mongrel out of the gemfile might fix issue at hand but then I would again have 'request too long' error when authenticating from google.
Is there a workaround to this? Should I be using a different version? If so...which?
I'v ran bundle exec locally even though heroku runs this on their end before deploying.
Try running bundle update daemons
Following advice I migrated ruby versions on the heroku stack: heroku stack:migrate bamboo-ree-1.8.7. I had to 'trick' git into pushing this change by committing a temporary file - no doubt there's a better way to do this!
It sounds like you have the problem only on your local machine, not on Heroku when it's deployed, correct?
Heroku uses Thin as webserver, and I highly recommend that locally, too.
Mongrel never really made the jump to Rails 3.x. And the default web server, Webrick, is not really industry strength, and I wouldn't be surprised if it had quirks like "request too long," etc.
Add the thin gem to your Gemfile.
The launch the server as follows:
rails s thin
And you should be cruising. Thin is also faster to start and handles multiple connections.
I think 3 problems here:
you're using Mongrel, as #Wolfram mentioned it's not a good idea. Add Thin to your Gemfile, bundle it, then use it with "rails s thin"
you made a little mod in Gem version probably, and it says you've activated a version then you've activated another one. Don't forget to bundle install then push it
Maybe it's better not only to update Bamboo stack but to use Cedar with "heroku create --stack cedar.

"uninitialized constant ActionView::CompiledTemplates::GMap" error when using ym4r_gm plugin

So I am somewhat new to Rails 3, and I am trying to integrate Google Maps with my Rails application.
I installed ym4r_gm from git://github.com/rorcraft.ym4r_gm.git, and I followed the tutorial on http://blog.brijeshshah.com/google-maps-in-ruby-on-rails/, and http://blog.brijeshshah.com/google-maps-in-rails-3/ .
After following the tutorial, I tried to run my application but I get an error that says "uninitialized constant ActionView::CompiledTemplates::GMap" regarding the "<%= raw Gmap.header %>" line. I have already installed the ym4r_gm-0.2.0 gem, and the ym4r-0.6.1 gem. Any suggestions on how to solve this problem?
Make sure that the gems you're trying to use in your Rails app are actually included in your Gemfile as well as being installed on your local machine.
Check out Ruby Gems for the exact line to include in your Gemfile. In this case, it's:
gem "ym4r_gm", "~> 0.2.0"
When you push your code to a production server like Heroku, the Gemfile tells Heroku which gems to pull down and install on the server. Also run this command when you're done.
bundle install

Getting SQLite3 errors even though I am trying to use PostgreSQL on Rails 3 development machine

Newbie question on Rails 3 development.
I am creating my first app and planning on deploying it to Heroku. Since Heroku uses PostgreSQL I thought I would change from SQLite on my development machine and move to PostgreSQL. Here is the gem file:
***source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'pg', :require => 'pg'
gem 'devise', '1.2.0'
group :development do
gem 'rspec-rails', '2.0.1'
end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
end***
I ran a page generator but whenever I try to view the pages locally, I get the following error:
no such file to load -- sqlite3
I don't understand where this SQLite error is coming from because I commented out SQLite from the gemfile.
The bigger question is rather it is neccesary to change my database gem at all. Is it better to develop with SQLite and let the host convert the databases?
TIA
The problem is probably in your database.yml, I'd guess that it looks something like this:
development:
adapter: sqlite3
but you want it to look more like this:
development:
adapter: postgresql
You'll probably want to apply the same change to the test: and production: sections as well; Heroku won't pay attention to the adapter but consistency is a good idea.
As far as the second question goes, I think you're better off developing and deploying on identical platforms. You can usually get away with developing on OSX or Windows but deploying on Linux if you're careful but you should have the same gem versions, same Ruby version, same Rails version, same database (including the version!), etc. Anything else is going to cause you a lot of pain and suffering sooner or later. So, kudos for developing on PostgreSQL when you're deploying on Heroku, good call.