app/models/effective/datatable.rb
def view=(view)
      @view = (view.respond_to?(:view_context) ? view.view_context : view)
      raise 'expected view to respond to params' unless @view.respond_to?(:params)

      load_cookie!
      assert_cookie!
      load_attributes!

      # We need early access to filter and scope, to define defaults from the model first
      # This means filters do knows about attributes but not about columns.
      initialize_filters if respond_to?(:initialize_filters)
      load_filters!
      load_state!

      # Bulk actions called first so it can add the bulk_actions_col first
      initialize_bulk_actions if respond_to?(:initialize_bulk_actions)

      # Now we initialize all the columns. columns knows about attributes and filters and scope
      initialize_datatable if respond_to?(:initialize_datatable)
      load_columns!

      # Execute any additional DSL methods
      initialize_charts if respond_to?(:initialize_charts)

      # Load the collection. This is the first time def collection is called on the Datatable itself
      initialize_collection if respond_to?(:initialize_collection)
      load_collection!

      # Figure out the class, and if it's activerecord, do all the resource discovery on it
      load_resource!
      apply_belongs_to_attributes!
      load_resource_search!

      # Check everything is okay
      validate_datatable!

      # Save for next time
      save_cookie!
    end
def view=(view)
      @view = (view.respond_to?(:view_context) ? view.view_context : view)
      raise 'expected view to respond to params' unless @view.respond_to?(:params)

      load_cookie!
      assert_cookie!
      load_attributes!

      # We need early access to filter and scope, to define defaults from the model first
      # This means filters do knows about attributes but not about columns.
      initialize_filters if respond_to?(:initialize_filters)
      load_filters!
      load_state!

      # Bulk actions called first so it can add the bulk_actions_col first
      initialize_bulk_actions if respond_to?(:initialize_bulk_actions)

      # Now we initialize all the columns. columns knows about attributes and filters and scope
      initialize_datatable if respond_to?(:initialize_datatable)
      load_columns!

      # Execute any additional DSL methods
      initialize_charts if respond_to?(:initialize_charts)

      # Load the collection. This is the first time def collection is called on the Datatable itself
      initialize_collection if respond_to?(:initialize_collection)
      load_collection!

      # Figure out the class, and if it's activerecord, do all the resource discovery on it
      load_resource!
      apply_belongs_to_attributes!
      load_resource_search!

      # Check everything is okay
      validate_datatable!

      # Save for next time
      save_cookie!
    end
Once the view is assigned, we initialize everything