3

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.

Community
  • 1
  • 1
Akshay Takkar
  • 500
  • 1
  • 7
  • 21
  • It seems the current version of the gem 'pg' i.e 0.17.1 does not support ruby 2.1 – Akshay Takkar Sep 27 '14 at 14:00
  • really? I'm stuck with this too, it seems that PostgreSQL rails and windows are not happy together – elios264 Oct 02 '14 at 20:48
  • I installed ruby 2.0.0..it seems to work with it..anyway ruby 2.1 is very unstable because a lot of gems were complaining while doing bundle install..use pik to manage different versions, its a great tool – Akshay Takkar Oct 03 '14 at 10:09

2 Answers2

2

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
    
Rots
  • 5,506
  • 3
  • 43
  • 51
  • I'm using 32-bit ruby 2.1.5 & DevKit (because many common gems still have trouble with 64-bit ruby) so I had to make sure: 1) 32-bit PostgreSQL was installed to match the gem and 2) the folder containing pg_config was in my Path. Otherwise, gem install pg failed. – ryanttb Dec 13 '14 at 21:42
0

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