-2

I'm trying to learn Rails, and running into a bit of a problem I don't understand. I started with Hartl's book and looking at this error message, it looks like something to do with what I was doing for that.

Now that I'm on a new project, I get this when I try to run a test on my routes file.

1) Error:
test_that_/login_route_opens_the_login_page(CursomRoutesTest):
ActiveRecord::StatementInvalid: Could not find table 'statuses'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:660:in `column_names'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:652:in `timestamp_column_names'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:585:in `block in table_rows'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `each'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `map'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `table_rows'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:494:in `block (3 levels) in create_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:492:in `each'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:492:in `block (2 levels) in create_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:491:in `block in create_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:168:in `disable_referential_integrity'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:476:in `create_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:895:in `load_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:849:in `setup_fixtures'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__3689392786993953837__setup__3124079788890242138__callbacks'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/TomEllis/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:35:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
Tom Ellis
  • 95
  • 2
  • 7
  • Search fail: http://stackoverflow.com/questions/6345319/could-not-find-table-users Still, could anyone explain what the reference to the rails3tutorial is inthe gems and how to remove it? – Tom Ellis Apr 29 '13 at 14:42
  • If you mean the `rails3tutorial2ndEd`, that's the name of your RVM gemset. – sevenseacat Apr 29 '13 at 14:49
  • Sorry, I don't understand what you mean. This is what I'm struggling with with Rails. I've found a couple of tutorials and guides that people rave about but they don't really explain all this stuff. I can get a wonderful social network running but I haven't got a bloody clue what an RVM gemset is, and I still don't understand what the db: commands really do. Can you tell this is my first back-end language?... – Tom Ellis Apr 29 '13 at 15:31

3 Answers3

4

You probably haven't run the rake task to prepare your test database:

bundle exec rake db:test:prepare
Lazarus Lazaridis
  • 5,803
  • 2
  • 21
  • 35
1

bundle exec rake db:test:clone

sanny Sin
  • 1,555
  • 3
  • 17
  • 27
1

I'm also a Rails newbie and I encountered a very similar problem (working on a different project, but getting errors referencing Hartl). After mulling it over in my head and googling, I believe I found the overall problem and solution.

Still, could anyone explain what the reference to the rails3tutorial is in the gems and how to remove it?

When we started the rails tutorial, Hartl advised us to run the following command:

$ rvm use 1.9.3@rails3tutorial2ndEd --create --default
Using /Users/mhartl/.rvm/gems/ruby-1.9.3 with gemset rails3tutorial2ndEd

(http://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=3.2#sec-install_rubygems)

The outcome?

...any time we open a new terminal window the 1.9.3@rails3tutorial2ndEd Ruby/gemset combination is automatically selected.

I fixed this by running:

 rvm use 1.9.3-p484 --default

(http://rvm.io/gemsets/using)

This made the "regular" gemset our default gemset (as opposed to our custom Hart tutorial gemset). I'm pretty sure "regular gemset" is the wrong term, but I'm still in the beginner phase, so my apologies to everyone who knows the correct term. I hope that helps!

jmsevold
  • 11
  • 1