# Send\_file confusion

**URL:** <https://www.ruby-forum.com/t/send-file-confusion/196717>\
**Category:** Ruby\
**Created:** [June 17, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/send-file-confusion/196717 "2008-06-17T23:40:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 17, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/send-file-confusion/196717/1 "2008-06-17T23:40:31Z")

</div>

Anyone see where I am going wrong here?

Error = undefined method `filename=’

Model

class Upload \< ActiveRecord::Base  
def upload=(upload\_field)  
self.filename = upload\_field.original\_filename  
self.content\_type = upload\_field.content\_type.chomp  
self.binary\_data = upload\_field.read  
end

end

Controller

def upload  
@upload = Upload.find(params[:id])  
send\_file(@upload.file,  
:filename =\> @upload.name,  
:type =\> @upload.content\_type,  
:disposition =\> “inline”)  
end

Form

**Upload a file:**  
 \<% form\_tag({:action =\> 'create'}, :multipart =\> true) do %\> \<%= file\_field("upload", "upload") %\>\<%= submit\_tag("Upload file") %\> \<% end %\>

Thanks for any help.  
Lynn

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2008, 12:05am UTC](https://www.ruby-forum.com/t/send-file-confusion/196717/2 "2008-06-18T00:05:10Z")

</div>

On Jun 17, 2008, at 14:38 , lynn wrote:

> Anyone see where I am going wrong here?

you’re sending a rails-related question to the ruby list instead of  
the rails list.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2008, 6:59am UTC](https://www.ruby-forum.com/t/send-file-confusion/196717/3 "2008-06-18T06:59:16Z")

</div>

2008/6/17 lynn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> self.binary_data = upload_field.read
> end
> 
> ```
> 
> end

I’m guessing your uploads table doesn’t have a string column called  
“filename”.
