It would help to have a look at the generated HTML and the ruby code in question. Make sure that your form's file field's name is "video [file]" (if the model that receives the file is indeed "Video") in order for a "def file=(thingie) ..." method in the Video model to work.
Also, make sure the form is multipart – the "<form ... " tag should have the property enctype="multipart/form-data". On 29 Dez., 15:00, Jenny <[email protected]> wrote: > I think what is tripping me up the most is figuring out how to access > this hash table that it returns. It does indeed seem like a fairly > simple, straightforward process, but I get the feeling that without > understanding the base underneath I'm doomed to do silly things > without realizing it. > > For example, > > <%= form_for(@video, :action => resource(:videos)) do %> > <p> > <%= text_field :name, :label => "Name : " %> > <%= file_field :file, :label => "File to Upload: " %> > > </p> > > <%= submit "Upload" %> > </p> > > That is the simple view code I have to upload the file I want...but I > can't get it to do anything, because I either get a method not found > error (if I don't define file as a method) or I get a wrong number of > arguments error, if I mimic Samo Korosec's code and have a file > (incoming_file) method. The file_field doesn't seem to pass anything > to my method at all, which makes me wonder how on earth I grab the > hash in the first place. I also tried specifically doing file=, but > that didn't seem to change anything other than letting me know that > there is the wrong number of arguments, still. > > I've tried working with paperclip as well...but even trying to import > it (after successfully installing it) gives me compile time errors > (all I'm doing is include Paperclip::Resources, like I've seen in some > tutorials) > > I feel like I understand everything, but that things aren't working > quite the way I seem to think they should... > > -Jenny > > On Dec 26, 2:02 pm, Ezra Zygmuntowicz <[email protected]> wrote: > > > On Dec 26, 2008, at 7:30 AM, Jenny wrote: > > > > Given that merb's major selling point is file uploads, I'm a bit > > > confused that there seems to be little to no documentation regarding > > > them. I had rails uploading files in five minutes, merb continues to > > > defeat me after 8 hours. > > > >http://wiki.merbivore.com/upload?s[]=upload > > > > The above is the ONLY resource I can find on merb file uploads, and it > > > seems incomplete, outdated or possibly both, because it makes little > > > since and I cannot for the life of me get it to work. > > > > Can anyone shed some light on this arcane process, or at least point > > > me towards some decent resources? > > > > -Jenny > > > What problems did you run into? It is literally a few lines of code > > > > to handle an upload. You just upload to an action, and in that action > > you will get a certain hash in the params that is like this: > > > {:filename => File.basename(filename), > > :content_type => content_type, > > :tempfile => body, > > :size => File.size(body.path)} > > > So you get the filename, the content type, :tempfile is the actual > > file on disk and :size is the size of the file. Do whatever you want > > with it from there. > > > Cheers- > > Ezra Zygmuntowicz > > [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" 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/merb?hl=en -~----------~----~----~----~------~----~------~--~---
