Error while deploying rails app to elastic beanstalk: "Command failed on instance"

I am trying to deploy rails app with postgresql db from Cloud9 to Elastic Beanstack; however, I am receiving this error:

eb deploy
    Creating application version archive "app-b98d-171206_004447".
    Uploading myapp/app-b98d-171206_004447.zip to S3. This may take a while.
    Upload Complete.
    INFO: Environment update is starting.                               
    INFO: Deploying new version to instance(s).                         
    ERROR: [Instance: i-045d80e51ef925d88] Command failed on instance. Return code: 1 Output: (TRUNCATED)...required)>'
    /var/app/ondeck/config/environment.rb:5:in `<top (required)>'
    /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load'
    /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>'
    Tasks: TOP => db:migrate => environment
    (See full trace by running task with --trace). 
    Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
    INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
    ERROR: Unsuccessful command execution on instance id(s) 'i-045d80e51ef925d88'. Aborting the operation.
    ERROR: Failed to deploy application.                                

    ERROR: ServiceError - Failed to deploy application.

I am not sure what's the problem. I have tried many different solutions but nothing seems to work. What can be the problem?

Update: 1. eb-activity.log

+ cd /var/app/ondeck
  + su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb db:migrate' webapp
  `/home/webapp` is not a directory.
  Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
  + '[' false = true ']'
  + su -s /bin/bash -c 'leader_only bundle exec rake db:migrate' webapp
  `/home/webapp` is not a directory.
  Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
  rake aborted!
<<<
  /var/app/ondeck/config/initializers/shrine.rb:4:in `fetch'
  /var/app/ondeck/config/initializers/shrine.rb:4:in `<top (required)>'
  /var/app/ondeck/config/environment.rb:5:in `<top (required)>'
  /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load'
  /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>'
  Tasks: TOP => db:migrate => environment
  (See full trace by running task with --trace) (Executor::NonZeroExitStatus)


[2017-12-06T01:33:57.106Z] INFO  [24030] - [Application update app-b98d-171206_013339@9/AppDeployStage0/AppDeployPreHook/12_db_migration.sh] : Activity failed.
[2017-12-06T01:33:57.107Z] INFO  [24030] - [Application update app-b98d-171206_013339@9/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2017-12-06T01:33:57.107Z] INFO  [24030] - [Application update app-b98d-171206_013339@9/AppDeployStage0] : Activity failed.
[2017-12-06T01:33:57.107Z] INFO  [24030] - [Application update app-b98d-171206_013339@9] : Completed activity. Result:
  Application update - Command CMD-AppDeploy failed
[2017-12-06T01:43:51.203Z] INFO  [24510] - [CMD-TailLogs] : Starting activity...
[2017-12-06T01:43:51.203Z] INFO  [24510] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2017-12-06T01:43:51.204Z] INFO  [24510] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2017-12-06T01:43:51.204Z] INFO  [24510] - [CMD-TailLogs/TailLogs] : Starting activity...
[2017-12-06T01:43:51.204Z] INFO  [24510] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...