Module: HasPublishing::ClassMethods
- Defined in:
- lib/has_publishing/class_methods.rb
Instance Method Summary collapse
-
#default_scope ⇒ Object
This default scope allows published and draft viewing modes to share the same code.
Instance Method Details
#default_scope ⇒ Object
This default scope allows published and draft viewing modes to share the same code. This is good. However if you need to access the other, draft from published or published from draft e.g from admin for editing, then you must explicitly use .unscoped to remove the default scope.
8 9 10 11 12 13 14 15 16 |
# File 'lib/has_publishing/class_methods.rb', line 8 def default_scope return scoped if HasPublishing.config.scope_records == false if Rails.env == (HasPublishing.config.published_rails_environment) published else draft end end |