lib/active_scaffold/extensions/action_view_rendering.rb
#
# Adds two rendering options.
#
# ==render :super
#
# This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
# Useful if you want to wrap an existing template. Just call super!
#
# ==render :active_scaffold => #{controller.to_s}, options = {}+
#
# Lets you embed an ActiveScaffold by referencing the controller where it's configured.
#
# You may specify options[:constraints] for the embedded scaffold. These constraints have three effects:
#   * the scaffold's only displays records matching the constraint
#   * all new records created will be assigned the constrained values
#   * constrained columns will be hidden (they're pretty boring at this point)
#
# You may also specify options[:conditions] for the embedded scaffold. These only do 1/3 of what
# constraints do (they only limit search results). Any format accepted by ActiveRecord::Base.find is valid.
#
# Defining options[:label] lets you completely customize the list title for the embedded scaffold.
#
# options[:xhr] force to load embedded scaffold with AJAX even when render_component gem is installed.
#
Adds two rendering options.
render :super

This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
Useful if you want to wrap an existing template. Just call super!

render :active_scaffold => #{controller.to_s}, options = {}+

Lets you embed an ActiveScaffold by referencing the controller where it's configured.

You may specify options[:constraints] for the embedded scaffold. These constraints have three effects:
the scaffold's only displays records matching the constraint
all new records created will be assigned the constrained values
constrained columns will be hidden (they're pretty boring at this point)

You may also specify options[:conditions] for the embedded scaffold. These only do 1/3 of what
constraints do (they only limit search results). Any format accepted by ActiveRecord::Base.find is valid.

Defining options[:label] lets you completely customize the list title for the embedded scaffold.

options[:xhr] force to load embedded scaffold with AJAX even when render_component gem is installed.
Adds two rendering options . render : super This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates . Useful if you want to wrap an existing template . Just call super! render : active_scaffold = > # { controller . to_s } options = {} + Lets you embed an ActiveScaffold by referencing the controller where it ' s configured . You may specify options [ : constraints ] for the embedded scaffold . These constraints have three effects : the scaffold ' s only displays records matching the constraint all new records created will be assigned the constrained values constrained columns will be hidden ( they ' re pretty boring at this point ) You may also specify options [ : conditions ] for the embedded scaffold . These only do 1 / 3 of what constraints do ( they only limit search results ) . Any format accepted by ActiveRecord :: Base . find is valid . Defining options [ : label ] lets you completely customize the list title for the embedded scaffold . options [ : xhr ] force to load embedded scaffold with AJAX even when render_component gem is installed .
def render(*args, &block)
      if args.first.is_a?(Hash) && args.first[:active_scaffold]
        render_embedded args.first
      elsif args.first == :super
        if @lookup_context 
          @_lookup_context ||= lookup_context
        else 
          @_view_paths ||= lookup_context.view_paths.clone
          @_last_template ||= lookup_context.last_template
        end
        result = super options_for_render_super(args[1])
        @lookup_context = @_lookup_context if @_lookup_context 
        lookup_context.view_paths = @_view_paths if @_view_paths 
        lookup_context.last_template = @_last_template if @_last_template 
        result
      else
        if @lookup_context 
          @_lookup_context ||= lookup_context
        else 
          @_view_paths ||= lookup_context.view_paths.clone
        end
        last_template = lookup_context.last_template
        current_view =
          if args[0].is_a?(Hash)
            {locals: args[0][:locals], object: args[0][:object]}
          else 
            {locals: args[1]}
          end
        view_stack << current_view if current_view
        @lookup_context = @_lookup_context if @_lookup_context , reset lookup_context in case a view render :super, and then render :partial
        lookup_context.view_paths = @_view_paths if @_view_paths , reset view_paths in case a view render :super, and then render :partial
        result = super
        view_stack.pop if current_view.present?
        lookup_context.last_template = last_template
        result
      end
    end
def render ( * args , & block ) if args . first . is_a? ( Hash ) && args . first [ :active_scaffold ] render_embedded args . first elsif args . first == :super if @lookup_context @_lookup_context ||= lookup_context else @_view_paths ||= lookup_context . view_paths . clone @_last_template ||= lookup_context . last_template end result = super options_for_render_super ( args [ 1 ] ) @lookup_context = @_lookup_context if @_lookup_context lookup_context . view_paths = @_view_paths if @_view_paths lookup_context . last_template = @_last_template if @_last_template result else if @lookup_context @_lookup_context ||= lookup_context else @_view_paths ||= lookup_context . view_paths . clone end last_template = lookup_context . last_template current_view = if args [ 0 ] . is_a? ( Hash ) { locals : args [ 0 ] [ :locals ] , object : args [ 0 ] [ :object ] } else { locals : args [ 1 ] } end view_stack << current_view if current_view @lookup_context = @_lookup_context if @_lookup_context lookup_context . view_paths = @_view_paths if @_view_paths result = super view_stack . pop if current_view . present? lookup_context . last_template = last_template result end end
Adds two rendering options.
Adds two rendering options .
# rails 6 # rails < 6 # rails 6 # rails < 6 # rails < 6 # rails 6 # rails < 6 # call is render 'partial', locals_hash # rails 6, reset lookup_context in case a view render :super, and then render :partial # rails < 6, reset view_paths in case a view render :super, and then render :partial
args
<not_specific>
block
<not_specific>