# RoutingError

**URL:** <https://www.ruby-forum.com/t/routingerror/190112>\
**Category:** Rails\
**Created:** [June 15, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/routingerror/190112 "2010-06-15T17:27:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aashishkiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@aashishkiran](https://www.ruby-forum.com/u/aashishkiran)\
**Post date:** [June 15, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/routingerror/190112/1 "2010-06-15T17:27:27Z")

</div>

hi, can anyone help me. i want to create an url to invoke create action  
of a controller. routes.rb has the routes. But i am getting error at  
line 23. i have @user variable.

user\_contact\_path(@user.id)  
I want generate url as : users/3/contacts to invoke contacts  
controller’s create action

* * *

ActionController::RoutingError in Contacts#index

Showing app/views/contacts/index.html.haml where line #23 raised:

user\_contact\_url failed to generate from {:controller=\>“contacts”,  
:user\_id=\>2, :action=\>“show”}, expected: {:controller=\>“contacts”,  
:action=\>“show”}, diff: {:user\_id=\>2}

Extracted source (around line #23):

## 20: %p or 21: %p Upload a vCard file to import people into your account. 22: %p 23: - form\_tag(user\_contact\_path(@user.id), :method =\> “post”) do 24: = file\_field\_tag “file” 25: = submit\_tag 26: .span\_2

thank you,  
aashish

---

<div class="post-metadata">

**Author:** ![aashishkiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@aashishkiran](https://www.ruby-forum.com/u/aashishkiran)\
**Post date:** [June 16, 2010, 10:47am UTC](https://www.ruby-forum.com/t/routingerror/190112/2 "2010-06-16T10:47:59Z")

</div>

Aashish K. wrote:

> hi, can anyone help me. i want to create an url to invoke create action  
> of a controller. routes.rb has the routes. But i am getting error at  
> line 23. i have @user variable.
> 
> user\_contact\_path(@user.id)  
> I want generate url as : users/3/contacts to invoke contacts  
> controller’s create action
> 
> * * *
> 
> ActionController::RoutingError in Contacts#index
> 
> Showing app/views/contacts/index.html.haml where line #23 raised:
> 
> user\_contact\_url failed to generate from {:controller=\>“contacts”,  
> :user\_id=\>2, :action=\>“show”}, expected: {:controller=\>“contacts”,  
> :action=\>“show”}, diff: {:user\_id=\>2}
> 
> Extracted source (around line #23):
> 
> 20: %p or  
> 21: %p Upload a vCard file to import people into your account.  
> 22: %p  
> 23: - form\_tag(user\_contact\_path(@user.id), :method =\> “post”)  
> user has many contact and if it is nested you can use simply  
> form\_tag([@user,@contact])  
> It will works for creating contact under index action  
> In controller create @contact = @user.contacts.new

Try This,  
Amar D.

> **[RailsTech.com is for sale | HugeDomains](https://www.hugedomains.com/domain_profile.cfm?d=railstech.com)**
>
> Customer service is our #1 priority. Get a premium domain for your website today. Financing available.

---

<div class="post-metadata">

**Author:** ![aashishkiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@aashishkiran](https://www.ruby-forum.com/u/aashishkiran)\
**Post date:** [June 18, 2010, 4:34am UTC](https://www.ruby-forum.com/t/routingerror/190112/3 "2010-06-18T04:34:43Z")

</div>

Bb Serviss wrote:

> What do you have in your routes.rb file to setup the custom route?
> 
> [Rails Routing from the Outside In — Ruby on Rails Guides](http://guides.rubyonrails.org/routing.html)

thank you for reply, it helped me  
answer is  
%p or  
%p Upload a vCard file to import people into your account.  
%p  
- form\_tag(user\_contacts\_path(@current\_user), :multipart =\>  
true) do

---

<div class="post-metadata">

**Author:** ![aashishkiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@aashishkiran](https://www.ruby-forum.com/u/aashishkiran)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/routingerror/190112/4 "2010-06-17T16:22:48Z")

</div>

What do you have in your routes.rb file to setup the custom route?

> **[Rails Routing from the Outside In — Ruby on Rails Guides](https://guides.rubyonrails.org/routing.html)**
>
> Rails Routing from the Outside InThis guide covers the user-facing features of Rails routing.After reading this guide, you will know: How to interpret the code in config/routes.rb. How to construct your own routes, using either the preferred...
