# Upload file error in rails(urgent)

**URL:** <https://www.ruby-forum.com/t/upload-file-error-in-rails-urgent/185722>\
**Category:** Rails\
**Created:** [March 25, 2010, 5:10am UTC](https://www.ruby-forum.com/t/upload-file-error-in-rails-urgent/185722 "2010-03-25T05:10:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [March 25, 2010, 5:10am UTC](https://www.ruby-forum.com/t/upload-file-error-in-rails-urgent/185722/1 "2010-03-25T05:10:22Z")

</div>

hi when i tried to runone of my file upload application in  
rails i am getting an error lik this. can any one please help  
mme?

ActionView::TemplateError (upload\_avatar\_user\_url failed to generate  
from {:format=\>“js”, :action=\>“upload\_avatar”, :controller=\>“users”,  
:id=\>nil}, expected: {:action=\>“upload\_avatar”, :controller=\>“users”},  
diff: {:format=\>“js”, :id=\>nil}) on line #2 of  
app/views/lists/\_import.html.haml:  
1: .remote  
2: - form\_for(@user, :url =\> upload\_avatar\_user\_path(@user, :format =\>  
“js”), :html =\> { :multipart =\> true, :target =\> “uploading”, :onsubmit  
=\> “$('user\_submit).disabled = true” }) do |f|  
3: = link\_to\_close avatar\_user\_path(@user)  
4: .section  
5: %small

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [March 25, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/upload-file-error-in-rails-urgent/185722/2 "2010-03-25T16:38:34Z")

</div>

Hi Tony,

Rails is telling you that your “upload\_avatar\_user\_path(@user, :format  
=\> ‘js’)” method call is not generating a correct route.

A couple things come to mind that could help to resolve the issue:

1. Make sure that you have defined the resource in your config/  
routes.rb

2. Make sure that the @user instance variable is not nil.

I’d probably need to see more code to help further.

Lake

---

<div class="post-metadata">

**Author:** ![murfhy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@murfhy](https://www.ruby-forum.com/u/murfhy)\
**Post date:** [March 25, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/upload-file-error-in-rails-urgent/185722/3 "2010-03-25T16:39:09Z")

</div>

Hi Tony,

Rails is telling you that your “upload\_avatar\_user\_path(@user, :format  
=\> ‘js’)” method call is not generating a correct route.

A couple things come to mind that could help to resolve the issue:

1. Make sure that you have defined the resource in your config/  
routes.rb

2. Make sure that the @user instance variable is not nil.

I’d probably need to see more code to help further.

Lake
