Q:

NoMethodError: undefined method `value_for_database' for # (Rails 5)

I've got a (brand new) Rails 5 project that's throwing errors when I try to run migrations. 
(I'm running Ruby 2.2.4 on a Raspberry Pi using PostgreSQL 9.4, but the same error message popped up when I first tried running the migration with SQLite.) 
So far, the only migration I've got is pretty basic:
class CreateAuthors < ActiveRecord::Migration[5.0]
  def change
    create_table :authors do |t|
      t.string :username
      t.timestamps
    end
  end
end

This results in the following output when I run rake db:migrate. 
pi@raspberrypi:~/projects/gnn $ rake db:migrate
== 20160915091621 CreateAuthors: migrating ====================================
-- create_table(:authors, {})
   -> 0.0283s
== 20160915091621 CreateAuthors: migrated (0.0287s) ===========================

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

undefined method `value_for_database' for #<Array:0x2a10470>
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `block in exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `each'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `map'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execute_and_clear'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:in `exec_query'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in `exec_insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:124:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:65:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:554:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/counter_cache.rb:128:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:123:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `block in _create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_create_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/timestamp.rb:68:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:534:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `block in create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:152:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/validations.rb:50:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:30:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `block in save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/suppressor.rb:45:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:51:in `create!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1247:in `record_version_state_after_migrating'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1212:in `block in execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
NoMethodError: undefined method `value_for_database' for #<Array:0x2a10470>
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `block in exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `each'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `map'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execute_and_clear'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:in `exec_query'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in `exec_insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:124:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:65:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:554:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/counter_cache.rb:128:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:123:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `block in _create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_create_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/timestamp.rb:68:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:534:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `block in create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:152:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/validations.rb:50:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:30:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `block in save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/suppressor.rb:45:in `save!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:51:in `create!' 
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1247:in `record_version_state_after_migrating'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1212:in `block in execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/pi/.rvm/gems/ruby-2.2.4@gnn/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Edit: Maybe worth saying that rake db:create ran fine. 
Here's my database.yml file as well, in case I've missed something there (I'm pretty green with PostgreSQL)
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: gnn_dev
  username: gnn
  password: Lorem123
  host: localhost
  port: 5432

A:

I have met the same issue in the middle of development.  Have found the reason. 
In my case I added a new gem 'imgurapi', that adds 'to_hash' to Array objects
class Array # :nodoc:
  # Skipped code 

  def to_hash # :nodoc:
    inject({}) { |hsh, (k,v)| hsh[k] = v  ; hsh }
  end unless method_defined?(:to_hash)
end

As result the calling the code exec_query(sql, name, binds) in gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in 'exec_insert' converts binds variable from Array to Hash type by the reason, that's good described here https://makandracards.com/makandra/36013-heads-up-ruby-implicitly-converts-a-hash-to-keyword-arguments.  As result we have the error, because this conversion is unexpected. 
Solution
Find the gem that defines 'to_hash' method for Array and get rid of this definition.  Good luck!