Method: Underworld::Dashboard::DSL::Base#scope

Defined in:
lib/underworld/dashboard/dsl/base.rb

#scope(name = nil, &block) ⇒ Object

Return the default scope for current properties object. scope will be used to fetch all the records for the given section. The Default implementation belongs to index section and return a page aware list of all the objects.

You can easily change it via the corresponding section dsl. For example in case of ‘index` section:

in_index do |index|
  index.scope do |params|
    YourModel.all
  end

  # or ...

  scope :my_scope
end

private
  def my_scope
    YourModel.where(...)

  end

Arguments:

  • params: Is the same params passed to controller action.



81
82
83
84
# File 'lib/underworld/dashboard/dsl/base.rb', line 81

def scope(name = nil, &block)
  return @default_scope = block if block_given?
  @default_scope = name.to_sym
end