开发者

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 beca开发者_如何学JAVAuse 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜