Sha256: 320a5af8f411c356b7ab774b7dfcea16e358f993939e443f13d8d15038ccacf6

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

<h4>&nbsp;</h4>
<%
  # 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
      if column.through_association?
        @constraints = {
          association.source_reflection.reverse => {
            association.through_reflection.reverse => parent_id
          }
        }
      else
        @constraints = { association.reverse => parent_id }
      end

      # generate the customized label
      @label = as_("%s for %s", active_scaffold_config_for(association.klass).label, format_column(@record.to_label))

      begin
        controller = active_scaffold_controller_for(association.klass)
      rescue ActiveScaffold::ControllerNotFound => error
        concat "#{error.class} - #{error.message}", binding
      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}
        ), binding
      end
    end
  end
%>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
antfarm-0.3.0 rails/vendor/plugins/active_scaffold/frontends/default/views/_nested.rhtml
antfarm-0.4.0 rails/vendor/plugins/active_scaffold/frontends/default/views/_nested.rhtml