RoutingError

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

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.

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

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

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