【发布时间】:2016-06-27 11:02:36
【问题描述】:
我正在尝试在我的 rails 4 应用程序中的 project.rb 模型中创建一个公式。
我在偏好表中有一个属性,称为延迟。我想计算一个用户的容差是否接近另一个用户所需的延迟。
在我的 project.rb 中,我尝试按如下方式执行此操作:
def publication_delay_variance
if @current_user.profile.organisation.preference.delay >= @project.profile.organisation.preference.delay
'No problems here'
elsif @current_user.profile.organisation.preference.delay * 90% >= @project.profile.organisation.preference.delay
"Close, but not quite there"
else @current_user.profile.organisation.preference.delay * 50% >= @project.profile.organisation.preference.delay
"We're not in alignment here"
end
end
当前用户是当前登录并与页面交互的当前用户。另一个用户是创建项目的用户。每个用户都有一个组织。每个组织都有偏好。我正在尝试比较它们。
谁能看到我做错了什么?我对此没有太多经验。我当前的尝试产生了这个错误:
syntax error, unexpected >=
...ence.publication_delay * 90% >= @project.profile.organisatio...
..
【问题讨论】:
标签: ruby-on-rails ruby operators formula