Need help reading a yaml file on upload with form

Here is the current basic information:

# new (views/file_uploads/new.html.erb)

<% form_for( @file_upload, :html => { :multipart => true } ) do |f| %>   <%= f.error_messages -%>   <p>     <%= f.label :upload, 'File' -%>     <%= f.file_field :upload -%>   </p>   <p><%= f.submit( 'Upload' ) %></p> <% end %>

# controller

def new   @file_upload = FileUpload.new end

def create   @theme_upload = FileUpload.new(params[:upload])

  respond_to do |format|     if FileUpload.save       flash[:notice] = 'Successfully Uploaded File.'       format.html { redirect_to(@file_upload) }     else       format.html { render :action => "new" }     end   end end

# model

class FileUpload < ActiveRecord::Base

  validates_presence_of :upload   attr_accessor :upload

end

# yaml file being uploaded

file:   name: default   author: First Last   date: 2010-01-01   stylesheets: true   javascripts: true   layouts: true   swfs: true

For instructional use here is what I see:

1. Admin user goes to form. 2. Admin user selects browse and finds the yaml file. 3. Admin users selects upload. 4. yaml file is read and parsed. 5. model saves the information from the yaml file into a record. 6. uploading begins in another routine based off what was recorded in step 5.

I hope that helps...

My problem is understanding what to do between steps 3 - 5.

Are you looking for local_path?

As in YAML.load_file params[:file_upload][:upload].local_path ?

pharrington wrote:

Are you looking for local_path?

As in YAML.load_file params[:file_upload][:upload].local_path ?

Thanks mate - yes this is exactly what I was looking for. I have not done a lot of work with reading files and am becoming familiar with how to do certain things with them. I couldn't figure out how to translate the local_path and now you showed me.

Many thanks!