2
votes

I am completing the tutorial Ruby on Rails 3 Essential Training through Lynda.com on Windows 7 64 using MySQL Server 5.7, MySQL Connector C 6.1 6.1.2, Ruby 1.9.3p392 (2013-02-22) [i386-mingw32] and Rails 4.0.2.

In the training, I am in the section on "Databases and Migrations" attempting to sync the database I have created in MySQL with my Rails project, however I have been running into an abort message.

The instructor asked my class to go through Command Prompt to open up our rails project and perform a Rake to build a "schema.rb" with this code:

$ rake db:schema:dump

And this abort message is the result each time I type that code in:

C:\Users\User\Documents\simple_cms>rake db:schema:dump

rake aborted!

Don't know how to build task 'db:schema:dump'

(See full trace by running task with --trace)

I have spent the last 24 hours uninstalling, downloading, and reinstalling multiple versions Ruby, Rails, both MySQL Server and Connector with the longest part of my time being spent learning how to add install the MySQL2 gem which I accomplished by downloading an older version mysql 0.2.6.

Yet despite this, that abort message has stayed constant.

Also, no DB rakes show when I type in rake -T as you see here:

rake about

rake assets:clean[keep]

rake assets:clobber

rake assets:environment

rake assets:precompile

rake cache_digests:dependencies

rake cache_digests:nested_dependencies

(where db should show but does not)

rake doc:app

...

rake test:all:db

...

rake tmp:create

Help?


Gem File as requested

source '...'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use mysql as the database for Active Record
gem 'mysql2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See ... for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: ...
gem 'turbolinks'

# Build JSON APIs with ease. Read more: ...
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

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

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
2
You would have to share this code you're using somewhere, like GitHub, it's really hard to figure it out from a tutorial like that.Maurício Linhares
you need to share your Gemfile and be sure that you have ran: bundle install, looks like it does not know which DB to use, and hope you did not create the project like this: rails new appname --skip-active-record that would not give you db related things in railsbjhaid
@bjhaid I just added the GemFile to the Question aboveuser2942719
@BakariPace did you run "bundle install" ??bjhaid
did you tried to run and --trace flag? if yes show us dump!Малъ Скрылевъ

2 Answers

0
votes

In the file database.yml, you should have something like:

default: &default
  adapter: mysql2
  encoding: utf8
  database: simple_cms_development
  pool: 5
  username: simple_cms
  password: secretpassword
  socket: /tmp/mysql.sock

development:
  <<: *default
  database: simple_cms_development

You should maybe check if database is correctly defined in your actual environment (development).

Comment: You don't have any db: with the rake -T command, so the problem is elsewhere.

0
votes

You will get this error

~/Project$ rake db:schema:dump
rake aborted!
Don't know how to build task 'db:schema:dump'
(See full trace by running task with --trace)

because active_record is not included in your rails application

add the following line to application.rb

require "active_record/railtie"

Now try,

~/Project$ rake -T

You should able to see the rake db commands

$ rails -T
rails about                              # List versions of all Rails frameworks and the environment
rails assets:clean[keep]                 # Remove old compiled assets
rails assets:clobber                     # Remove compiled assets
rails assets:environment                 # Load asset compile environment
rails assets:precompile                  # Compile all the assets named in config.assets.precompile
rails cache_digests:dependencies         # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_com...
rails cache_digests:nested_dependencies  # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment....
rails db:create                          # Creates the database from DATABASE_URL or config/database.yml for the current RAI...
rails db:drop                            # Drops the database from DATABASE_URL or config/database.yml for the current RAILS...
rails db:environment:set                 # Set the environment value for the database
rails db:fixtures:load                   # Loads fixtures into the current environment's database
rails db:migrate                         # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rails db:migrate:status                  # Display status of migrations
rails db:rollback                        # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rails db:schema:cache:clear              # Clears a db/schema_cache.dump file
rails db:schema:cache:dump               # Creates a db/schema_cache.dump file
rails db:schema:dump                     # Creates a db/schema.rb file that is portable against any DB supported by Active R...
rails db:schema:load                     # Loads a schema.rb file into the database
rails db:seed                            # Loads the seed data from db/seeds.rb
rails db:setup                           # Creates the databa