我正在尝试根据 ana ActionController before_filter 确定的某些标准设置默认范围。在控制器中:
before_filter :authorize
...
def authorize
if some_condition
@default_scope_conditions = something
elsif another_condition
@default_scope_conditions = something_else
end
end
ActiveRecord 内部
default_scope :conditions => @default_scope_conditions
但这似乎不起作用,调用了 before 过滤器但未设置 default_scope 。您能否告诉我我做错了什么以及如何解决它或建议我其他一些方法来实现它。