Hi Guys
i''ll give you my model, controller(not entire one) and view that i
already
have
model
class MetroUpload < ActiveRecord::Base
def self.save(metro_upload)
File.open("Metro_SQL/#{metro_upload[''name'']}/metro.sql",
"w") {
|f|
f.read(metro_upload[''sql_file''].rewind)
f.write(metro_upload[''sql_file''].read)
}
end
end
controller
def create
if @post = MetroUpload.save(@params["metro_upload"])
breakpoint
flash[:notice] = ''Metro Upload was successfully
created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
virew
<div id="update_div">
<h1>New Metro file upload</h1>
<%= form_remote_tag (:update =>"update_div",:multipart =>
true,
:url =>{:action => ''create''}) %>
<%= render :partial => ''form'' %> # see the partial
<%= submit_tag "Upload it" %>
<%= end_form_tag %>
<%= link_to ''Back'', :controller =>
''badger_cab_erp_admin'' %>
</div>
_form.rhtml # my partial
<%= error_messages_for ''metro_upload'' %>
<!--[form:metro_upload]-->
<p><label for="metro_upload_file">Attach your sql
file</label><br/>
<!--<%= file_field ''metro_upload'',
''metroSQL'' %></p>-->
<input type="file" name="metro_upload[sql_file]" />
</p>
<!--[eoform:metro_upload]-->
my problem is i can upload a file in this way, but there is nothing in my
file (there is nothing in its contents)
only file will be created with the given name - zero length file
Plz any one can tell me how to fix this ( i want to upload the file with its
contents)
Thx
Kushan
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---