如何在通话链中间添加评论?
当我尝试在调用链的中间添加注释时,我看到Ruby抛出解析错误:
Tag.joins(:taggings)
# Wanted to add comment here cause it's long
# and takes multiple lines
.where(...)
.where(...)
.where(...)
# And here
.group(...)
.order(...)
Run Code Online (Sandbox Code Playgroud)
更改为以下结构:
Tag.joins(:taggings).
# Comment 1
# Comment 2
where(...).
where(...).
where(...).
# And here
group(...).
order(...)
Run Code Online (Sandbox Code Playgroud)
最后的方法.点将指示解析器表达式尚未结束,并且逻辑方法链将到达。
| 归档时间: |
|
| 查看次数: |
184 次 |
| 最近记录: |