How to install sqlite or postgresql on windows 8 for a ruby on rails setup?

对着背影说爱祢 提交于 2020-01-13 16:30:31

问题


I've been trying to install a database as part of my ruby on rails setup. I'm running a 64 bit windows 8, a x64 based machine. My ruby version is 2.1.3p242, rails version is 4.0.0, sqlite3 version is 3.8.6 and postgresql version is 9.3 I first tried to install sqlite3 by following the steps given in this SO answer but I get this error

`require': Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid.

My database.yml has 'sqlite3' as the value for the adapter key for all three environments.
Next I try to installed postgresql which was installed properly. I fired up the pgadmin3 GUI and started the database server. But when I start the rails server. I get the following error

C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/pg-0.17.1-x64-mingw32/lib/pg.rb:10:in `re
quire': cannot load such file -- 2.1/pg_ext (LoadError)

Thanks.


回答1:


You need to use the pre release of pg.

  1. Install

    gem install pg -v 0.18.0.pre20141117110243 --pre
    
  2. Add to your Gem file

    gem 'pg', '~> 0.18.0.pre20141117110243'
    
  3. Update with Bundle

    bundle update
    



回答2:


If you want to use PostgreSQL you'll need to do 2 things:

  1. Install PostgreSQL on Windows using these instructions

  2. Configure your rails project to use PostgreSQL this way:

rails new todo --database=postgresql

On the related note, if you want to do web development with Ruby on Rails, I recommend you to install Ruby, Gems, Git, Rails and IDE. All instructions are in the Start Programming Now book



来源:https://stackoverflow.com/questions/26075258/how-to-install-sqlite-or-postgresql-on-windows-8-for-a-ruby-on-rails-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!