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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.