简体   繁体   中英

unable to execute the rake:db command successfully

I am facing this error while doing the rake db:migrate part. I am following the Michael Hartl tutorial and I seem lost at this point and have been trying out a lot of solutions available online but they don't seem to be too much of a help. I am not sure how to solve this problem. I am a total newbie. Am I doing something wrong? Can you point out where? BTW this is the first model I am creating.

bundle exec rake db:migrate 
DEPRECATION WARNING: config.whiny_nils option is deprecated and no longer works. (called from block in <top (required)> at /home/aravind/coderor/demo_app1/config/environments/development.rb:10)
DEPRECATION WARNING: Model based mass assignment security has been extracted out of Rails into a gem. Please use the new recommended protection model for params or add `protected_attributes` to your Gemfile to use the old one.

To disable this message remove the `whitelist_attributes` option from your
`config/application.rb` file and any `mass_assignment_sanitizer` options
from your `config/environments/*.rb` files.

See http://guides.rubyonrails.org/security.html#mass-assignment for more information.

DEPRECATION WARNING: The Active Record auto explain feature has been removed.

To disable this message remove the `active_record.auto_explain_threshold_in_seconds`
option from the `config/environments/*.rb` config file.

See http://guides.rubyonrails.org/4_0_release_notes.html for more information.

==  CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:

private method `String' called for         #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000004606298>/home/aravind    /coderor    /demo_app1/db/migrate/20130628051457_create_users.rb:4:in `block in change'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:625:in `block in method_missing'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `block in say_with_time'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:597:in `say_with_time'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:617:in `method_missing'
/home/aravind/coderor/demo_app1/db/migrate/20130628051457_create_users.rb:3:in `change'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:571:in `exec_migration'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:554:in `block in migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:553:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:709:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract    /database_statements.rb:202:in `transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:1005:in `ddl_transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:920:in `block in migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `each'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:916:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/railties    /databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Here is the migration file

class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.String :name
t.String :email
t.timestamps
end
end
end

The error says it all.

private method `String' called for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000004606298>/home/aravind/coderor/demo_app1/db/migrate/20130628051457_create_users.rb:4:in `block in change'

Change String to string on line 4 in db/migrate/20130628051457_create_users.rb

It looks like you spelled 'string' with a capital letter, ie 'String'. Ruby is case-sensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM