Changeset 2

Show
Ignore:
Timestamp:
07/17/2006 03:42:02 AM (2 years ago)
Author:
matthew
Message:

* Fixed interactive saving on an edit screen with a (read-only) child

list

* Added an Expires header of one day to the asset action, to cut down on

the number of requests being made for every page view

Files:

Legend:

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

    r1 r2  
    121121 
    122122      # Save child objects 
     123      # FIXME: This is currently quite entirely broken. At least it 
     124      # isn't preventing the main object from being saved, so it should 
     125      # be okay for read-only lists. 
    123126      model.admin_fieldsets.each do |set| 
    124127        case set.fieldset_type 
     
    126129          children = @object.send( set.field ) 
    127130          child_class = children.build.class 
    128           child_params = params[params[:model].to_s + '_' + set.field.to_s
     131          child_params = params["#{params[:model]}_#{set.field}"
    129132          child_params.each do |child_index, child_info| 
     133            next unless Hash === child_info 
    130134            o = child_info[:id] ? child_class.find( child_info[:id] ) : children.build 
    131             child_info.delete :id 
    132             if set.field_options.all? {|k,v| v[:required] ? child_info[k].blank? : true } 
    133               o.destroy 
    134             else 
    135               unless o.update_attributes child_info 
    136                 render :action => 'edit' and return 
    137               end 
     135#            child_info.delete :id 
     136            unless o.update_attributes child_info 
     137              render :action => 'edit' and return 
    138138            end 
    139139          end if child_params 
     
    201201 
    202202    filename = roots.map {|dir| File.join( dir, params[:path] ) }.detect {|file| File.exist?( file ) } 
    203     render :text => File.read(filename), :content_type => mime_type 
     203    raise "Unable to locate asset #{File.join(params[:path]).inspect} in any of #{roots.size} asset roots" unless filename 
     204 
     205    # FIXME: Should we do this in develpment mode? "Development" 
     206    # generally means of the application, but what if we're working on a 
     207    # theme? 
     208    @headers['Expires'] = (Time.now + 1.day).utc.to_formatted_s(:rfc822) 
     209 
     210    send_file filename, :type => mime_type 
    204211  end 
    205212end