Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以就像你可以做@items.active.first第一个项目一样,有没有办法选择别的东西,比如第 56 个?
@items.active.first
显然@items.active.fiftysixth不起作用,但是还有其他方法可以访问它吗?
@items.active.fiftysixth
当集合是关系时,您可以使用偏移量(.first 只是limit 1在 SQL 中转换为)
limit 1
@items.active.offset(55).first
或者,如果它是一个数组:
@items.active[55]