【发布时间】:2016-03-13 23:44:57
【问题描述】:
我正在浏览一个遗留代码库,我看到类似这样的内容:
def all_story_links
StoryLink.complete.where("
(storyable_type = 'Recipe' AND storyable_id = ?)
OR
(storyable_type = 'RecipeStep' AND storyable_id IN (?))
OR
(storyable_type = 'RecipeIngredient' AND storyable_id IN (?)
)", id, recipe_step_ids, recipe_ingredient_ids)
end
在 where 方法中调用了什么?它是什么?是阿雷尔吗?这是否存在,因为没有解决此问题的 ActiveRecord 便捷方法?是 SQL 还是 Arel?有什么好的资源可以快速学习 AREL?
【问题讨论】:
-
"在 where 方法里面叫什么?" -> 一个 SQL 查询...?不,这不是使用 arel 包装器。要求教程不是 Stack Overflow 的主题。抱歉 :-( Ruby on Rails Guides 非常好,应该为您提供大部分入门信息。
标签: ruby-on-rails arel