📜  参数化范围 rails 代码 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:36.783000             🧑  作者: Mango

代码示例1
scope :by_post_status, -> (post_status) { where('post_status = ?', post_status) }
scope :published, -> { by_post_status("public") }
scope :draft, -> { by_post_status("draft") }