Christopher Nash Christopher Nash - 4 months ago 7x
Ruby Question

trouble generating new rails controller

I am new to ruby on rails development. I am currently having difficulties generating a new rails controller. here is what I input into the terminal:

$ rails generate controller static_pages home help

here is the response I receive:

:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded.
Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)

I am also using Heroku for production so I initially removed sqlite3 because Heroku cant use it by doing:

$ gem uninstall sqlite3

and I removed it from my gemfile and gemfile.lock. Was this a mistake? Any guidance would be much appreciated.


The error is because the config/database.yml file still has sqlite3 as the database adapter for the development database.

If you know which database you want to use for your local development database, set the appropriate database adapter in this file.

Heroku can't use sqlite3; however, you can use sqlite3 for your local development database, and specify postgres or mysql for production database.

Since you are a total beginner, I would recommend following the steps from a detailed tutorial as it is till you become familiar with the various concepts. Michael Hart's Rails Tutorial book is available for free online, and is a very good resource for beginner rails developers.