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_embedded(options)
      require 'digest/md5'
      remote_controller = options[:active_scaffold]
      eid = Digest::MD5.hexdigest(params[:controller] + options.to_s)
      eid_info = {loading: true}
      eid_info[:constraints] = options[:constraints] if options[:constraints]
      eid_info[:conditions] = options[:conditions] if options[:conditions]
      eid_info[:label] = options[:label] if options[:label]
      options[:params] ||= {}
      options[:params].merge! :eid => eid, :embedded => eid_info
      id = "as_#{eid}-embedded"
      url_options = {controller: remote_controller.to_s, action: 'index', id: nil}.merge(options[:params])
      if controller.respond_to?(:render_component_into_view, true) && !options[:xhr]
        controller.send(:render_component_into_view, url_options)
      else
        url = url_for(url_options)
        content_tag(:div, :id => id, :class => 'active-scaffold-component', :data => {:refresh => url}) do
          model = remote_controller.to_s.sub(%r{.*/}, '').singularize
          content_tag(:div, :class => 'active-scaffold-header') do
            content_tag(:h2) do
              link_label = options[:label] || active_scaffold_config_for(model).list.label
              link_to(link_label, url, remote: true, class: 'load-embedded', data: {error_msg: as_(:error_500)}) <<
                loading_indicator_tag(url_options)
            end
          end
        end
      end
    end
def render_embedded ( options ) require 'digest/md5' remote_controller = options [ :active_scaffold ] eid = Digest :: MD5 . hexdigest ( params [ :controller ] + options . to_s ) eid_info = { loading : true } eid_info [ :constraints ] = options [ :constraints ] if options [ :constraints ] eid_info [ :conditions ] = options [ :conditions ] if options [ :conditions ] eid_info [ :label ] = options [ :label ] if options [ :label ] options [ :params ] ||= { } options [ :params ] . merge! :eid => eid , :embedded => eid_info id = "as_#{eid}-embedded" url_options = { controller : remote_controller . to_s , action : 'index' , id : nil } . merge ( options [ :params ] ) if controller . respond_to? ( :render_component_into_view , true ) && ! options [ :xhr ] controller . send ( :render_component_into_view , url_options ) else url = url_for ( url_options ) content_tag ( :div , :id => id , :class => 'active-scaffold-component' , :data => { :refresh => url } ) do model = remote_controller . to_s . sub ( %r{ .*/ } , '' ) . singularize content_tag ( :div , :class => 'active-scaffold-header' ) do content_tag ( :h2 ) do link_label = options [ :label ] || active_scaffold_config_for ( model ) . list . label link_to ( link_label , url , remote : true , class : 'load-embedded' , data : { error_msg : as_ ( :error_500 ) } ) << loading_indicator_tag ( url_options ) end end end end end
Adds two rendering options.
Adds two rendering options .
# It is important that the EID hash remains short as to not contribute # to a large session size and thus a possible cookie overflow exception # when using rails CookieStore or EncryptedCookieStore. For example, # when rendering many embedded scaffolds with constraints or conditions # on a single page. # parse the ActiveRecord model name from the controller path, which # might be a namespaced controller (e.g., 'admin/admins')
options
<not_specific>