0

I've encountered a problem. I recently cloned an application on github and tried to launch it using the Rails Console. When I typed in the name of one of the tables, I received this message.

Project
=> Project(Table doesn't exist)

Here is the Schema.rb file

ActiveRecord::Schema.define(version: 20120504152649) do

  create_table "projects", force: true do |t|
    t.string   "name"
    t.string   "point_scale",         default: "fibonacci"
    t.date     "start_date"
    t.integer  "iteration_start_day", default: 1
    t.integer  "iteration_length",    default: 1
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "default_velocity",    default: 10
  end

  create_table "projects_users", id: false, force: true do |t|
    t.integer "project_id"
    t.integer "user_id"
  end
end

Here is the Projects Migration

class CreateProjects < ActiveRecord::Migration
  def self.up
    create_table :projects do |t|
      t.string :name
      t.string :point_scale, :default => 'fibonacci'
      t.date :start_date
      t.integer :iteration_start_day, :default => 1
      t.integer :iteration_length, :default => 1

      t.timestamps
    end
  end

  def self.down
    drop_table :projects
  end
end

The Gemfile

source 'http://rubygems.org'

ruby '2.1.0'

gem 'rails', '4.0.2'
gem 'sass-rails', '~> 4.0.1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.1'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
gem 'ejs'
gem "compass-rails", "~> 1.1.2"
gem "devise", "~> 3.2.0"
gem 'transitions', '0.1.9', :require => ["transitions", "active_record/transitions"]
gem 'rails-i18n'
gem 'configuration'
gem 'rails-observers', '~> 0.1.2'
# gem 'protected_attributes'
gem 'jquery-ui-rails'

group :production do
  gem 'pg'
  # This helps with serving assets and log files on the heroku platform.
  # See https://github.com/heroku/rails_12factor
  # https://devcenter.heroku.com/articles/rails4#logging-and-assets
  gem 'rails_12factor'
end

group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'jasmine', '~> 1.3.2'
  gem 'capybara'

  gem 'database_cleaner'
end

Here is my database.yml file

# SQLite
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

I've tried migrating the database

rake db:migrate
=>undefined method `database_authenticatable' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x007fd7832ed418>/Users/richardhamilton/MyProjects/fulcrum/db/migrate/20110210082458_devise_create_users.rb:4:in `block in up'

I've tried creating the database

rake db:create
db/development.sqlite3 already exists

I've tried loading the schema

rake db:schema::load
rake aborted!
Don't know how to build task 'db:schema::load'

I don't know why it couldn't find a table.

matt
  • 78,533
  • 8
  • 163
  • 197
George Lucas
  • 197
  • 1
  • 8
  • 1
    I assume you ran the basic rake commands before attempting to start anything? – MCBama Jul 18 '14 at 21:05
  • I just tried that and got undefined method `database_authenticatable' for #/Users/richardhamilton/MyProjects/fulcrum/db/migrate/20110210082458_devise_create_users.rb:4:in `block in up' – George Lucas Jul 18 '14 at 21:06
  • What is "that" that you tried? rake db:create? rake db:schema:load? which one? Or both? – MCBama Jul 18 '14 at 21:07
  • rake db:migrate. I didn't create the tables myself. I just cloned the app. I then tried migrating the data. Do I need to rollback or reset the database? – George Lucas Jul 18 '14 at 21:07
  • You have to create the databases before you attempt to load them. run `rake db:create db:schema:load` and that should fix your problem – MCBama Jul 18 '14 at 21:08
  • Running rake db:create returns db/development.sqlite3 already exists and running rake db:schema:load returns Don't know how to build task 'db:schema::load'. I'll try to add more info – George Lucas Jul 18 '14 at 21:10
  • alright so at some point you generated the databases or perhaps they came over with the clone. run `rake db:drop db:create db:schema:load` instead. And the reason `db:schema:load` failed the first time was because you put `db:schema::load` instead which is wrong. – MCBama Jul 18 '14 at 21:11
  • Nice, that solved my problem. Now, sqlite finds the tables. Thank you very much. – George Lucas Jul 18 '14 at 21:15
  • Sure thing. Gonna make an answer if you wouldn't mind marking it for me. Internet points and things xD – MCBama Jul 18 '14 at 21:15

1 Answers1

2

run rake db:drop db:create db:schema:load and you should be up and running.

MCBama
  • 1,432
  • 10
  • 18