我正在使用 Rails 5。我想根据 user_id 字段搜索模型。我的桌子看起来像这样
cindex=# \d user_notifications;
Table "public.user_notifications"
Column | Type | Modifiers
--------------------+---------+-----------------------------------------------------------------
id | integer | not null default nextval('user_notifications_id_seq'::regclass)
user_id | integer |
crypto_currency_id | integer |
price | integer | not null
buy
| boolean | not null
但是当我尝试像这样查找模型时
@user_notification = UserNotification.find_by_user(current_user)
我得到错误
undefined method `find_by_user' for UserNotification:Class
查找我的字段的简单(Rails)方法是什么?