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

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.

Related

I can't migrate the database of my Rails app on Heroku with sqlite

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

Neo4j.rb 2.0 and devise 2.0. Is there any way?

I want to use Neo4j database and JRuby on Rails to build a new web project. (I really need Neo4j or other graph database for this)
I am using neo4j 2.0 gem and trying to make authentication with Devise and Omniauth. Is there any way this combination will work?
I tried devise-neo4j but it is not compatible with neo4j.rb 2.0. I know that the last commit here says it is for neo4j.rb 2.0 but
gem 'neo4j'
gem 'devise-neo4j'
gives the following error when bundling:
Bundler could not find compatible versions for gem "neo4j":
In Gemfile:
devise-neo4j (>= 1.0.2) java depends on
neo4j (~> 1.1.1) java
neo4j (2.0.0.rc2)
I also tried the normal devise gem with neo4j:
gem 'neo4j'
gem 'devise'
but when I run rails g devise:install I get NameError: uninitialized constant User.
I searched and tried this a lot but couldn't get it working.
Does anyone know a good solution to this?
Or what is the right way to get this functionality (login with email/password and facebook,google,yahoo and twitter)? Oh, I know I can code it myself, but I would really like to use something already done.
My devise-neo4j fork is not released to rubygems.org, which means you have to specify it in the Gemfile file as:
gem 'devise', '1.5.3'
gem 'devise-neo4j', :git => 'git://github.com/andreasronge/devise-neo4j.git'
Notice that devise-neo4j does currently not work with devise 2.0.

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.

How to downgrade Rails version?

I create my rails application in version 3.0.7.
now i want to deploy my application, but the server is only support 3.0.3
how can i downloadgrade my application?
thanks
replace
gem 'rails','3.0.7'
with
gem 'rails', '3.0.3'
in your gemfile
Then run bundle
On a second note why not upgrade the server to rails 3.0.7?
Unless I'm mistaken... you can't. Well, you can, by:
Creating a new app
Bundle-installing all the necessary plugins, gems, etc
Copying over app files, configs, helpers, tests, everything
Running tests and seeing what doesn't now work
Making changes where required
Unfortunately, I don't believe there exists an easier way.

Should I not be using the mysql gem now for rails 3.0 applications?

I'm starting a new rails 3.0 application that uses geometry data types in the database to store polygons. I have installed the spatial adapter gem but it requires the mysql gem and is incompatible with the mysql2 gem.
Is it ok to use the mysql gem instead of the mysql2 gem? Am I going to have problems down the road?
Thanks!
No, you won't have any troubles. The main push for using the mysql2 gem over the previous mysql gem is that the mysql gem currently blocks I/O while waiting for a response from the db server, while the mysql2 gem doesn't. Unless you're focusing on optimizing your app for asynchronous components and concurrency, you probably won't notice the difference.
You're perfectly safe using the mysql gem with Rails 3. I've used it without any difficulties.