【发布时间】:2014-01-15 23:49:32
【问题描述】:
这是我的输入样本,它有 3 个 slug url,
["[\"apple-iphone\"", " \"blackberry\"", " \"htc\"]"]
如何将上述 slug 转换为 id 以便我可以将其用作 Post.where(category_id: converted_ids)
我使用 friendly_id 创建 slug url。
考虑我有两个关系
- 类别(类别名称将充当 slug)。
- posts(category_id 存储为参考)。
并将其视为我的网址
http://localhost:3000/apple-iphone_htc_blackberry
现在我怎样才能找到所有posts with id of apple-iphone, htc, blackberry.
【问题讨论】:
标签: ruby-on-rails