search for: uploaded_file

Displaying 20 results from an estimated 39 matches for "uploaded_file".

2006 Jun 20
2
Problem with "can''t dump anonymous class Class"
...{RAILS_ROOT}/app/controllers/enrollment_admin_controller.rb:34:in `save_global_document'' -e:4 Any ideas on how to fix this? If I change GlobalDocument to Document below, it works fine. Here is the relevant code: ** Models ** class Document < ActiveRecord::Base attr_accessor :uploaded_file def after_create if !File.exists?(File.dirname(self.file_path)) Dir.mkdir(File.dirname(self.file_path)) end if @uploaded_file.instance_of?(Tempfile) FileUtils.copy(@uploaded_file.local_path, self.file_path) else File.open(self.file_path, "wb") { |...
2011 Mar 26
2
upload file, read first 10 lines.
I have a csv file and in my controller: uploaded_file = params[:upload][:csv].read @rows << FasterCSV.parse(uploaded_file) I want to put in @rows only the first 10 lines but the read method reads all the file. How can I do? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To p...
2006 Jul 26
4
Upload File
I got this error: NoMethodError in PictureController#new You have a nil object when you didn''t expect it! The error occured while evaluating nil.uploaded_file= and the line code is here: @picture.uploaded_file = @params[''picture_file''] -- Posted via http://www.ruby-forum.com/.
2007 May 16
1
Rails, Mongrel and Rmagick
...nd read it into rmagick to verify that it''s an image. For some reason I can''t catch an exception thrown by rmagick inside the app. After an invalid image file is uploaded the process just hangs. I have to kill mongrel and restart to use the app again. img = Magick::Image::read(@uploaded_file.path).first This line above should throw a Magick::ImageMagickError exception. I''ve confirmed this with a simple ruby script. I''ve tried adding breakpoints and as soon as this line is reached there''s no coming back, even the breakpointer hangs. I pasted the method fro...
2006 Jun 08
1
Permissions on uploaded files, TinyFile
Hi, im getting a little trouble with this, im using TinyFile as the example to upload files http://wiki.rubyonrails.com/rails/pages/TinyFile/versions/20 All goes well but the files uploaded are saved with permissions 600 (linux) and in the case of images arent showed on the browser(but uploaded and stored in the server without problems) i have to manually ftp to the uploaded files folder and
2006 Jun 19
3
can''t dump anonymous class Class
...ciationDocument" t.column :association_id, :integer # attributes for type="LocationDocument" t.column :location_id, :integer end end def self.down drop_table :documents end end ** Models ** class Document < ActiveRecord::Base attr_accessor :uploaded_file def after_create if !File.exists?(File.dirname(self.file_path)) Dir.mkdir(File.dirname(self.file_path)) end if @uploaded_file.instance_of?(Tempfile) FileUtils.copy(@uploaded_file.local_path, self.file_path) else File.open(self.file_path, "wb") { |f| f...
2006 Jun 09
8
[how can i delete a file system..please help]
Hi, I''m trying to delete a file system (<xml_26548975.xml>) File.delete("xml_26548975.xml") But I get this error: "Permission denied - ./script/../config/../uploads/xml_26548975.xml". Why? -- Cheers, ioana k&a http://boulangerie.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL:
2006 Sep 05
2
Mongrel and umask for uploaded files
...are created with.. I''ve also tried putting "File.umask(022)'' inside environment.rb but that doesn''t make a difference. To handle uploads, I have a resource model which does the following in the before_create filter: def before_create return FileUtils.copy( @uploaded_file.local_path, self.path_to_file) if @uploaded_file.instance_of?(Tempfile) # else File.open(self.path_to_file, "w") { |f| f.write(@uploaded_file.read) } end If anyone has any other hints for how to change the umask, please let me know, this is driving me crazy! Thanks, Mike
2006 Aug 15
8
AGAIN: file object treated as string
...write_file(params[:image]) redirect_to(:controller => ''shto'', :action => ''index'') else render(:action => :get) end end def write_file(uploaded_file) uploaded_file[''picture''].rewind File.open("pictures/upload/#{@image.id}.#{@image.extention}", "wb") { |f| f.write(uploaded_file[''picture''].read) } end end MODEL: class Image < Activ...
2006 Jan 09
1
Saving an upload
...NOT NULL, picture_id integer NOT NULL, "position" integer NOT NULL, primary key (film_id, picture_id) ); Here''s the Ruby: film.rb: class Film < ActiveRecord::Base has_and_belongs_to_many :pictures, :join_table => "films_pictures" attr_writer :uploaded_files attr_reader :uploaded_files validates_presence_of :name, :description, :has_subtitles, :is_censored end picture.rb: class Picture < ActiveRecord::Base has_many :films has_many :comics acts_as_list :picture_id attr_writer :parent_id attr_writer :type validates_presence_of :...
2013 Oct 10
12
What's the best way to approach reading and parse large XLSX files?
...39;creek'' class UploadFiles < ActiveRecord::Base after_commit :process_files attr_accessible :inventory, :material_list has_one :inventory has_one :material_list has_attached_file :inventory, :url=>"/:current_user/inventory", :path=>":rails_root/tmp/users/uploaded_files/inventory/inventory.:extension" has_attached_file :material_list, :url=>"/:current_user/material_list", :path=>":rails_root/tmp/users/uploaded_files/material_list/material_list.:extension" validates_attachment_presence :material_list accepts_nested_attributes_...
2006 Mar 29
7
Uploading files and writing them to server?
Where should I look for information on how to use Rails and Ruby to accept the upload of a file and then to save that file to the file system of my server? I''m reading the "Uploading a file" section of Agile Web Dev with Rails, but it''s geared toward saving the file in the database. Any advice? Thanks, Jeff -- Posted via http://www.ruby-forum.com/.
2006 Jan 05
4
testing file uploads
Hi all, I was wondering about the class used when rails receives file uploads. Sometimes it appears to be a File, and other times it is a StringIO. Also it has methods such as original_filename that don''t appear to belong to either of these classes. I ask because I''m trying to work out how to test my fil upload related models and controllers. Is there some standardised way of
2006 May 29
3
IFRAME based RJS - responds_to_parent
...ond to the parent document of your page. Make Ajaxy file uploads by posting the form to a hidden iframe, and respond with RJS to the parent window. Example ======= Controller: class Test < ActionController::Base def main end def form_action # Do stuff with params[:uploaded_file] responds_to_parent do render :update do |page| page << "alert($(''stuff'').innerHTML)" end end end end main.rhtml: <html> <body> <div id="stuff">Here is some stuff</di...
2006 Aug 15
0
file object treated as a string
...write_file(params[:image]) redirect_to(:controller => ''shto'', :action => ''index'') else render(:action => :get) end end def write_file(uploaded_file) uploaded_file[''picture''].rewind File.open("pictures/upload/#{@image.id}.#{@image.extention}", "wb") { |f| f.write(uploaded_file[''picture''].read) } end end My image mod...
2019 Feb 14
3
32 seconds vs 72 minutes -- expected performance difference?
...fied vers= in fstab, but something strange happened. While `man mount.cifs` claims that the following are allowed -- 1.0, 2.0, 2.1, 3.0, 3.1.1 (or 3.11) -- few of them failed with strange errors: # mount -t cifs -o rw,username=myuser,password=[REDACTED],uid=myuser,gid=myuser,vers=3.11 //[REDACTED]/uploaded_files /home/myuser/shared mount error(11): Resource temporarily unavailable Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) # tail /var/log/syslog [...] Feb 14 12:57:04 prod-backoffice kernel: [105926.746067] CIFS VFS: failed to connect to IPC (rc=-11) Feb 14 12:57:04 prod-backoffice ke...
2006 Dec 30
2
Another RSpec on Rails issue: how to test send_file()
Hi! Today I needed to implement some controller code, that uses send_file() to send image data. How can this be tested / specified with RSpec? bye, Tobias
2006 May 19
9
Resize uploaded image file without creating temp file?
Hi, I need to take a single uploaded image file and save three resized versions of it, a thumbnail, normal and large version. I was planning on doing this in my model by having an array of geometry strings and looping through them, each time saving a new image object resized to the correct geometry. I know that file column does similar stuff, but I would prefer to have a separate database row
2006 May 01
10
large file storing in postgres sucks?
...e (in my functional tests) the following code: upload = fixture_file_upload(''/files/podcast.mp3'', ''audio/mpeg'') post :create, :product => valid_product, :media => { :image => upload } And then in the controller: blob = Blob.create :data => uploaded_file.read When /files/podcast.mp3 is 32 megabytes and I run the test, memory spikes hugely. My laptop quickly began swapping out memory and became unusable. top showed the memory usage of the Ruby process to be about 400MB and growing. Is there something stupid that I''m doing? Joe
2006 Feb 17
1
validate() with has_many association
...model has_many :images def thumbnail=(uploaded_image) # form has a file upload field named painting[:thumbnail] add_image_by_size(uploaded_image, THUMBNAIL) end private def add_image_by_size(file, image_size) if existing_image = get_image_by_size(image_size) then if existing_image.uploaded_file?(file, image_size) existing_image.save else #handle the fact that it didn''t save end else # a new image is being associated with the painting image = Image.new image.uploaded_file(file, image_size) self.images << image end e...