1

Topic: trouble getting started - trouble connecting to a db

Hi,

I'm trying to get get going on a rails tutorial and get get past the installation. I'm a newbie, so I'm just bumbling along

1 . ran "rails new app1." - app created but bundler fails (An error occured while installing sqlite3 (1.3.5),)

2.  changed the gemfile to explicitly call for "gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' (this is the most recent version that works on osx 10.5)"

3. ran "bundle install" - success

4. try to view the default app and see the error "ActiveRecord::ConnectionNotEstablished"

5. looked in config/database.yml. It says "database: db/development.sqlite3"

6. looked in db/ - no database here.

Anybody have an idea what I need to do?

OSX 10.5.8 (leopard)
rails 3.2.0
ruby 1.9.2

*Sorry to be coming to this forum with a setup question like this. I know its probably tedious. I hope to be back soon with some more interesting contributions.

Last edited by nc (2012-02-19 15:44:19)

Re: trouble getting started - trouble connecting to a db

rake db:migrate ?

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

3

Re: trouble getting started - trouble connecting to a db

Thanks Brad.

I get this error 
"rake aborted!
: Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)"

Was a db supposed to have been created during "rails new app?"

Re: trouble getting started - trouble connecting to a db

Go ahead and follow those instructions.

rake db:migrate will create the database if it doesn't exist.

You have to generate database migration files, there are numerous ways to do that

enter

rails generate
or
rails g

same thing,  it will show you all the things the rails generator can do,  most of them will ultimately generate database migration files,  and the database will get set up when you run

rake db:migrate

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

5

Re: trouble getting started - trouble connecting to a db

Thanks for the help. Unfortunately still no cigar:

Tried: "rails generate migration prayer"
Then: "rake db:migrate"
Got: rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)

Tried: gem install activerecord-sqlite3-adapter
Got: ERROR:  Could not find a valid gem 'active-record-sqlite3-adapter' (>= 0) in any repository
ERROR:  Possible alternatives: activerecord-jdbcsqlite3-adapter, activerecord-sqlserver-adapter, activerecord-simpledb-adapter, activerecord-nul
ldb-adapter, activerecord-spatialite-adapter

any more ideas?

Re: trouble getting started - trouble connecting to a db

Copy paste your Gemfile here so we can look at it.

Remember to edit your topic title and add "[SOLVED]" if your question has been answered!

Follow me!

7

Re: trouble getting started - trouble connecting to a db

source 'https://rubygems.org'

gem 'rails', '3.2.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

Re: trouble getting started - trouble connecting to a db

Try replacing your 'sqlite' line with simply sqlite3. If that doesn't work, try doing what the error says to do: Add 'activerecord-sqlite3-adapter' to the gemfile

Remember to edit your topic title and add "[SOLVED]" if your question has been answered!

Follow me!

9

Re: trouble getting started - trouble connecting to a db

gem sqlite3 tries to install the most recent version (not compatible with OSX 10.5)

adding gem install activerecord-sqlite3-adapter to the gemfile or running gem install activerecord-sqlite3-adapter in terminal returns:

Could not find gem 'activerecord-sqlite3-adapter (>= 0) ruby' in any of the gem sources listed in your Gemfile

10

Re: trouble getting started - trouble connecting to a db

Thanks wesf90 & Brad for your help.

I've managed (after a lot of pain) to get a default app up and running. For what it's worth, this is what I did:

1. Upgraded to OSX 6
2. Installed all updated to the operating system & xcode
3. Reinstalled Ruby
4. Reinstalled rails
5. Regenerated the app
6. ran bundle install using the default gemfile.

I guess anyone running into this problem would want an easier fix so I guess try from the bottom and move up until it works smile.

From reading around, I think the problem is with compiling the sqlite3 gem. It needs to be compiled using the same compiler used to compile ruby and/or rails.
*I could easily be completely wrong about this. I have no idea what I'm talking about.