I am rather new to Ruby and have been following along with the book \"Ruby On Rails 3 Tutorial - Learn Ruby by Example - by Michael Hartl\". I am currently in Chapter 3 whic
Update the adapter in config/database.yml file to the database name being used by your application and restart your rails. This will resolve the issue.
For me it got reset to some other DB name, so it was giving error. After updating it to "sqlite3", it worked fine.
Add this to your Gemfile:
gem 'sqlite3-ruby', :require => 'sqlite3'
i am new to it but this might be pretty helpful(if you are in development just check development leave production and test environments):
Create a database and give it a name.
Open up .config/database.yml
adapter: mysql2
database: specify_your_newly_created_database #check if its automatically updated or not
pool: 5
username: your designated username.
password: your designated password.
host: localhost
$ rails server
=> Booting WEBrick
=> Rails 3.2.9 application starting in development on http:// 0. 0. 0 .0 :3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-12-12 23:31:50] INFO WEBrick 1.3.1
[2012-12-12 23:31:50] INFO ruby 1.9.3 (2012-11-10) [i386-mingw32]
[2012-12-12 23:31:50] INFO WEBrick::HTTPServer#start: pid=4068 port=3000
Started GET "/demo/index" for 127.0.0.1 at 2012-12-12 23:32:40 +0545
Connecting to database specified by database.yml
Processing by DemoController#index as HTML
Rendered demo/index.html.erb within layouts/application (0.0ms)
Compiled demo.css (46ms) (pid 4068)
and so on...........
if your'e just trying to solve the ActiceRecord then this will solve the problem and display your first hello page. This is the problem that occurs sometime since rails searches for the database though we have nothing to do with database when dealing with the first hello page, so just check it once if not the we will solve it together. Cheers!
If you have in your Gemfile something like:
gem 'sqlite3-ruby', '> 1.2.0', :require => 'sqlite3'
replace it with:
gem 'sqlite3'
Try updating the sqlite3 gem. bundle update sqlite3
I had the same problem, I started the sample-app from scratch and used this gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'sqlite3'
group :development do
gem 'rspec-rails', '2.6.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
end
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
This solved the problem for me :)