rubymine - why is form_ tag code is not working in ruby mine 5.4.3.2.1? -


i building ror application in ruby mine .but following doesn't seems run `

<%= form_tag upload_index_path({:action => 'uploadfile'},                                :multipart => true)  %> <p><label for="upload_file">select file</label> :   <%= file_field 'upload', 'datafile' %></p> <%= submit_tag "upload" %> <% end %>`  code in view file. trying build site can upload files. appears when click upload button file doesn't uploaded url changes. why that?? 

this controller code

class uploadcontroller < applicationcontroller   def index     render :file => 'app\views\upload\uploadfile.html.erb'   end   def uploadfile     post = datafile.save(params[:upload])     render :text => "file has been uploaded successfully"   end end 

this model code

class datafile < activerecord::base   # attr_accessible :title, :body   def self.save(upload)     name =  upload['datafile'].original_filename     directory = "public/data"     # create file path     path = file.join(directory, name)     # write file     file.open(path, "wb") { |f| f.write(upload['datafile'].read) }   end end 

i have not been able find solution. have been trying week.

in form_tag declaration, remove multipart path options follows:

<%= form_tag upload_index_path({:action => 'uploadfile'}) , :multipart => true  %>                         <p>         <label for="upload_file">select file</label> :         <%= file_field 'upload', 'datafile' %>     </p>      <%= submit_tag "upload" %>  <% end %> 

http://api.rubyonrails.org/classes/actionview/helpers/formtaghelper.html#method-i-form_tag


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -