Ошибка миграции при работе с гемом Device


(Вячеслав) #1

Добрый день! Я смотрю скринкасты на ютуб по разработке магазина на Rails и сам пытаюсь повторить за автором. Были мелкие ошибки, но все смог решить. Но при добавлении гема Devise я не могу сделать миграцию. Ругается > rake aborted!

StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 2, expected 0…1)

Не могу понять к чему это относиться, т.к. делаю добавляю все по официальному мануалу.
Вот полный вывод терминала:

== 20180715172151 DeviseCreateUsers: migrating ================================
– drop_table(:users)
-> 0.0395s
– create_table(:users)
-> 0.0072s
– add_index(:users, :email, {:unique=>true})
-> 0.0021s
– add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0034s
== 20180715172151 DeviseCreateUsers: migrated (0.0532s) =======================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 2, expected 0…1)
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:50:in new' /var/lib/gems/2.3.0/gems/protected_attributes_continued-1.3.0/lib/active_record/mass_assignment_security/validations.rb:15:increate!’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1328:in record_version_state_after_migrating' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1293:inblock in execute_migration_in_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1343:in block in ddl_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:254:inblock in transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:230:in block in within_new_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:227:inwithin_new_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/transactions.rb:212:intransaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1343:in ddl_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1291:inexecute_migration_in_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1263:in block in migrate_without_lock' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1262:ineach’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1262:in migrate_without_lock' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1212:inmigrate’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1036:in up' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1011:inmigrate’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/tasks/database_tasks.rb:172:in migrate' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/railties/databases.rake:60:inblock (2 levels) in ’
/var/lib/gems/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>’

Caused by:
ArgumentError: wrong number of arguments (given 2, expected 0…1)
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:50:in new' /var/lib/gems/2.3.0/gems/protected_attributes_continued-1.3.0/lib/active_record/mass_assignment_security/validations.rb:15:increate!’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1328:in record_version_state_after_migrating' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1293:inblock in execute_migration_in_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1343:in block in ddl_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:254:inblock in transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:230:in block in within_new_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:227:inwithin_new_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/transactions.rb:212:intransaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1343:in ddl_transaction' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1291:inexecute_migration_in_transaction’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1263:in block in migrate_without_lock' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1262:ineach’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1262:in migrate_without_lock' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1212:inmigrate’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1036:in up' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/migration.rb:1011:inmigrate’
/home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/tasks/database_tasks.rb:172:in migrate' /home/slavik/.gem/ruby/2.3.0/gems/activerecord-5.2.0/lib/active_record/railties/databases.rake:60:inblock (2 levels) in ’
/var/lib/gems/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>’
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

P.S. В миграции я сначала удалаю таблицу юзеров, т.к. до этого ее создал, но с этим проблем нет.


#2
  1. Никогда не учись программированию по скринкастам ютюба, ибо на выходе неизменно получишь полную хрень. Есть доки, официальные и неофициальные, по ним и работай. Предпочтение англоязычным.
  2. Неоднократно использовал devise, ошибок такого рода не наблюдал, не помню. Прежде всего, постарайся локализовать проблему. Например, создай новый app, пробундли devise и сделай миграцию. Если получится, уже круг поиска сужается, верно? Ты ведь даже название гема написал с ошибкой, что априори не вызывает желания всерьез анализировать твои траблы.