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 -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What do you have in your routes.rb file to setup the custom route? http://guides.rubyonrails.org/routing.html On Jun 15, 11:27 am, Aashish Kiran <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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") > do > 24: = file_field_tag "file" > 25: = submit_tag > 26: .span_2 > -------------------------------------------------------------------------------- > > thank you, > aashish > -- > Posted viahttp://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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bb Serviss wrote:> What do you have in your routes.rb file to setup the custom route? > > http://guides.rubyonrails.org/routing.htmlthank 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 -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.