将入站控制器参数映射到资源中的命名作用域
要将作用域应用到特定资源,只需调用 apply_scopes:
class GraduationsController < ApplicationController
has_scope :featured, type: :boolean
has_scope :by_degree
has_scope :by_period, using: %i[started_at ended_at], type: :hash
def index
@graduations = apply_scopes(Graduation).all
end
end
``` 然后,对于每次请求 `index` 操作, _HasScope_ 将自动应用以下作用域:暂无开放 Issues,或尚未同步最近议题。