On Jan 12, 1:47 pm, Alpha Blue <[email protected]> wrote: > 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 > > ================= > > What I would like to be able to do is eventually upload a number of file > folders with files based off what is listed in a YAML file being > selected and read. > > For instance, if I could info = YAML.load_file(the_path_to_upload_file) > I would get the following: > > => {"file"=>{"name"=>"default", "date"=>Fri, 01 Jan 2010, > "author"=>"First Last", "swfs"=>true, "javascripts"=>true, > "layouts"=>true, "stylesheets"=>true}} > > and would be able to read/use the information later on. > > My problem is understanding how to call/access that information using > the template above. If I run it right now, of course what will happen > is a record will be saved with nil information because nothing is truly > being sent/saved properly. > > However, when viewing it in the console, the following information is > being sent via parameters: > > Parameters: {"commit"=>"Upload", > "authenticity_token"=>"4IW8zdd8WyHFBjxMJgxZbPtPp0XlJiPInxtlywfaf74=", > "file_upload"=>{"upload"=>#<File:C:/Users/MyUser/AppData/Local/Temp/RackMul > tipart.3076.2>}} > > If I open the Rackmultipart.3076.2 file it does match the exact same > contents of the yaml file being uploaded. > > Again, I'm unsure of how to go about defining a method to simply read > the yaml file and parse its contents using an upload button. > -- > Posted viahttp://www.ruby-forum.com/.
Are you looking for local_path? As in YAML.load_file params[:file_upload][:upload].local_path ?
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

