Changeset 29

Show
Ignore:
Timestamp:
12/13/2006 12:12:59 AM (2 years ago)
Author:
matthew
Message:

Improved saving of child tables -- the processor is now run, so
associations are correctly translated to their corresponding columns.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/auto-admin/lib/auto_admin_configuration.rb

    r28 r29  
    249249            idx += 1 
    250250            o = children.build 
     251            children.delete o 
    251252            build_object(builder, o, idx, 
    252253              "#{o.class.human_name} ##{n}") 
  • trunk/auto-admin/lib/auto_admin_controller.rb

    r26 r29  
    135135 
    136136      # Save attributes on the primary object 
    137       flash[:notice] = @object.inspect 
    138137      @object.attributes = params[params[:model]] 
    139138      unless @object.save 
     
    181180              set_name = 'Child list' 
    182181              set_name = set.name if set.respond_to?(:name) && !set.name.blank? 
    183               flash[:warning] = "Failed to #{o.new_record? ? 'add' : 'change'} the #{o.class.name.titleize.downcase} \"#{o.to_label}\" (#{set_name}). " 
     182              flash[:warning] = "Failed to #{o.new_record? ? 'add' : 'change'} the #{o.class.name.titleize.downcase} \"#{o.to_label}\" (#{set_name})" 
     183              o.errors.each_full {|s| flash[:warning] << "; " << s } 
     184              flash[:warning] << ". " 
    184185              render :action => 'edit' and return 
    185186            end 
  • trunk/auto-admin/lib/auto_admin_simple_theme.rb

    r23 r29  
    391391      options = @options.dup 
    392392      options.update extra_options 
    393       name = "#{@object_name}_#{inner_object_name}" 
    394       table_params = @controller.params[name] 
    395       yield self.class.new( inner_object, name, extra_options[:model], @controller, table_params, options ) if table_params 
     393      if table_params = @controller.params[inner_object_name] 
     394        table_params.each do |row_number, row_params| 
     395          if row_params 
     396            yield self.class.new( inner_object, inner_object_name, extra_options[:model], @controller, row_params, options ) 
     397          end 
     398        end 
     399      end 
    396400    end 
    397401    def with_object(object, object_name=@object_name)