search for: attachment_field

Displaying 3 results from an estimated 3 matches for "attachment_field".

2006 Jul 04
0
Uploading files - getting size
...id="attachment_title" name="attachment[title]" size="30" type="text" /> <input id="attachment_attachment" name="attachment[attachment]" size="30" type="file" /> In the Attachment-model is: def attachment=(attachment_field) self.name = base_part_of(attachment_field.original_filename) self.content_type = attachment_field.content_type.chomp #self.size = attachment_field.file.size self.data = attachment_field.read end def base_part_of file_name name = File.basename(file_name) name.gsub(/[^\w._-]/,...
2006 Jul 03
0
Multiple File Upload
...chment project = Project.find(@params[:id]) begin project.attachments.create(params[:attachment]) rescue flash[:attachment_error] = "Error at Upload" end redirect_to :action => "edit_project", :id => project end attachment_model: ----------------- def attachment=(attachment_field) self.name = base_part_of(attachment_field.original_filename) self.content_type = attachment_field.content_type.chomp self.data = attachment_field.read end def base_part_of file_name name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end edit_project.rhtml: ---------...
2007 Jul 05
2
undefined method `original_filename' for "random.jpg":String
...uot;, "comment"=>"asdf"} As you can see, the one working correctly passes an actual file object whereas the broken one just passes a string. Here are the relevant files: models/attachment.rb: class Attachment < ActiveRecord::Base belongs_to :journal def attachment=(attachment_field) self.name = base_part_of(attachment_field.original_filename) self.content_type = attachment_field.content_type.chomp self.data = attachment_field.read end def base_part_of(file_name) name = File.basename(file_name) name.gsub(/[^\w._-]/, '''') end end co...