即使我尝试在 Rails 3 开发机器上使用 PostgreSQL,也会出现 SQLite3 错误
关于 Rails 3 开发的新手问题。
我正在创建我的第一个应用程序并计划将其部署到 Heroku。由于 Heroku 使用 PostgreSQL,我想我应该从开发机器上的 SQLite 更改为 PostgreSQL。这是 gem 文件:
***source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'pg', :require => 'pg'
gem 'devise','1.2.0'
组:开发
gem 'rspec-rails','2.0.1'
结束
组:测试
gem 'rspec','2.0.1'
gem 'webrat',' 0.7.1'
end***
我运行了页面生成器,但每当我尝试在本地查看页面时,都会收到以下错误:
没有要加载的文件——sqlite3
我不明白这个 SQLite 错误是从哪里来的,因为我从 gemfile 中注释掉了 SQLite。
更大的问题是,有必要更改我的数据库 gem。使用SQLite开发并让主机转换数据库是不是更好?
TIA
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能出在您的
database.yml
中,我猜它看起来像这样:但您希望它看起来更像这样:
您可能希望对还有
test:
和product:
部分; Heroku 不会关注适配器,但一致性是个好主意。至于第二个问题,我认为最好在相同的平台上进行开发和部署。如果你小心的话,你通常可以在 OSX 或 Windows 上进行开发,但在 Linux 上进行部署,但你应该有相同的 gem 版本、相同的 Ruby 版本、相同的 Rails 版本、相同的数据库(包括版本!)等等。迟早会给你带来很多痛苦和磨难。因此,当您在 Heroku 上部署时,在 PostgreSQL 上进行开发值得称赞,这是一个很好的选择。
The problem is probably in your
database.yml
, I'd guess that it looks something like this:but you want it to look more like this:
You'll probably want to apply the same change to the
test:
andproduction:
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.