在栏杆上的适当红宝石标签在红宝石矿中插值

发布于 2025-02-09 05:48:46 字数 681 浏览 1 评论 0原文

想要在Ruby Mine中正确设置院子,任何建议都将不胜感激。

class Entity < ApplicationRecord
  belongs_to :user
end

# @param user [User]
def authorized_for_user?(user)
  return true
end

# @param entity [Entity]
def check_authorization(entity)
  authorized_for_user?(entity.user) # The line that gets the following error
end

由于.user是通过一个活动记录属于与关联,因此我得到的警告是:

Incompatible types
Required: User
Passed: ActiveRecord::Associations::BelongsToAssociation<User>

任何想法如何使此方法自动插入。会有意想不到的副作用吗?

我想在重要的方法和服务上尽可能接近记录的打字。我很感谢有关如何实现这一目标的任何好的教程 /指南?

Want to setup Yard properly in Ruby Mine and any advice would be appreciated.

class Entity < ApplicationRecord
  belongs_to :user
end

# @param user [User]
def authorized_for_user?(user)
  return true
end

# @param entity [Entity]
def check_authorization(entity)
  authorized_for_user?(entity.user) # The line that gets the following error
end

Since .user is through an active record belongs-to association, the warning I get is:

Incompatible types
Required: User
Passed: ActiveRecord::Associations::BelongsToAssociation<User>

Any idea how to make this automatically interpolate either. Will there be unintended side effects?

I want to get as close to documented typings as possible on important methods and services. I would appreciate any good tutorials / guides on how to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文