When a simple Rails app is deployed on Heroku, some features do not work in a production environment.
Sorry for the rudimentary content, but I would appreciate it if you could lend me some help.

My skill level

・ Over 1 year programming history
・ Rails, Heroku history about 2 months
・ Rails tutorial completed

Problem summary

I'm making a task management app.
It works without problems in the development environment, but if you deploy to Heroku, an error will occur when adding a new task.
In the production environment, you can log in and edit existing tasks.

Work steps up to the problem and detailed error messages

■ Reproduction procedure
a. https://d0ne1s-todo-app.herokuapp.com/Access
b. Login with "[email protected]" "hogehoge"
c. Click "Add Task"
d. Enter 1-20 character task and add

■ Error message
・ Browser

We're sorry, but something went wrong.
If i am the application owner check the logs for more information.</Code></pre>
<p><br />
・ Heroku log</p>
<pre><code>2019-11-27T11: 11: 38.516775 + 00: 00 app [web.1]: I, [2019-11-27T11: 11: 38.516693 # 4] INFO-: [f2e95d17-0d66- 40fb-99ab-8d01437d67bf] Parameters: {"utf8" =>"✓", "authenticity_token" =>"yzSSuu2njJDRR9/1hrkwGEXeyTqk5Da6tFUUdHHiORbRBKYvsEpgV7XBhrRNFGlS9xlSCZLYDUR1RF8 =" Oh "

 "commit" =>"Register"}2019-11-27T11: 11: 38.520458 + 00: 00 app [web.1]: D, [2019-11-27T11: 11: 38.520309 # 4] DEBUG-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf] [1m [36mUser Load (0.9ms) [0m [1m [34mSELECT "users". * FROM "users" WHERE "users". "Id" = $1 LIMIT $2 [0m [["id", 1],

 ["LIMIT", 1]]
2019-11-27T11: 11: 38.525173 + 00: 00 app [web.1]: I, [2019-11-27T11: 11: 38.525057 # 4] INFO-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf] Completed 500 Internal Server Error in 8ms (ActiveRecord: 0.9ms)
2019-11-27T11: 11: 38.526315 + 00: 00 app [web.1]: F, [2019-11-27T11: 11: 38.526202 # 4] FATAL-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf]
2019-11-27T11: 11: 38.526503 + 00: 00 app [web.1]: F, [2019-11-27T11: 11: 38.526430 # 4] FATAL-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf] ActiveModel :: UnknownAttributeError (unknown attribute 'user_id' for Task.):
2019-11-27T11: 11: 38.526643 + 00: 00 app [web.1]: F, [2019-11-27T11: 11: 38.526535 # 4] FATAL-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf]
2019-11-27T11: 11: 38.526754 + 00: 00 app [web.1]: F, [2019-11-27T11: 11: 38.526688 # 4] FATAL-: [f2e95d17-0d66-40fb-99ab-8d01437d67bf] app/controllers/tasks_controller.rb: 13: in `create '
Expected results, actual results, grounds for expectations

・ Expected results
Transition to the task list screen, one task has been added

・ Actual results
Heroku error message is displayed

・ Grounds for expectations
Because it works as expected in the local development environment

The problem environment

-Device: MacBook Pro (13-inch, 2017)
・ OS: macOS Mojave 10.14.5
・ Shell: zsh
・ Ruby: 2.3.7
・ Rails: 5.1.7
・ Development environment database: SQLite
・ Heroku
-Plan: Hobby-dev
-PG Version: 11.6
-Status: Available

Possibly related settings and codes


An error occurred when modifying

belongs_to, has_many and the associated task>create action.

Create action
@task = current_user.tasks.build (task_params)
There is a problem in the part.


heroku rails console
→ user = User.first
→ task = user.tasks.build (title: "hello world")
→ task.save
→ Successful new task registration

As a possible cause for me

・ current_user is not working
・ Task_params is not working
・ Problems caused by different types of databases used in development and production environments (SQLite and Postgres)
->In addition to the create action of tasks_controller, the task model and user model have been changed to associate with belongs_to and has_many.
(Migration in production environment is complete.)


Since the session function cannot be used in the Rails console, the procedure that the logged in user registers a task cannot be reproduced. It has become clogged.

If i know someone, please give me advice.
Thanks for your cooperation.