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

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

http://guides.rubyonrails.org/routing.html

Aashish Kiran 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 Daxini
Http://railstech.com

Bb Serviss wrote:

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

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