Sha256: ae62c28d9726a555112db70abd8c150bd25ed4620690d3aa253d97b12e1fdf19

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

<%
  # TODO: shouldn't this logic happen in the controller action instead of the template?
  # Actually, maybe we should make render :active_scaffold work in the controller, and not even have a _nested.rhtml?

  # This assumes that the association is included as a column in the active_scaffold_config.columns collection
  associated_columns = []
  associated_columns = params[:associations].split(" ") unless params[:associations].nil?
  unless associated_columns.empty?
    parent_id = params[:id]
    associated_columns.each do | column_name |
      # find the column and the association
      column = active_scaffold_config.columns[column_name]
      association = column.association

      # determine what constraints we need
      @constraints = { association.reverse => parent_id }

      # generate the customized label
      @label = as_(:nested_for_model, :nested_model => active_scaffold_config_for(association.klass).list.label, :parent_model => format_value(@record.to_label))

      begin
        controller = active_scaffold_controller_for(association.klass)
      rescue ActiveScaffold::ControllerNotFound => error
        concat "#{error.class} - #{error.message}"
      else
        concat render(:active_scaffold => controller.controller_path,
          :constraints => @constraints,
          :conditions => association.options[:conditions],
          :label => h(@label),
          :params => {:nested => true, :parent_column => column_name, :parent_model => association.active_record.name, :format => 'html'}
        )
      end
    end
  end
%>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb
brisk-bills-0.8.1 vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb