hi,
im want to delete a user from a view controled by a different
controler than user_controller.rb.
from the view a make:
<td><%= user.username %></td>
<td><%= user.email %></td>
<td><%= user.sign_in_count %></td>
<td><%= user.amis %></td>
<td><%= link_to ''Show'', user %></td>
<td><%= link_to ''Edit'', edit_user_path(user)
%></td>
<td><%= link_to ''Destroy'', user, :confirm =>
''Are you
sure?'', :method => :delete %></td>
the url of this view is : http://localhost:3000/user_admins/index
when i clik in the link_to ''Show'' it dispatch to:
http://localhost:3000/users/1
and for edit : http://localhost:3000/users/1/edit
the probleme is when i want to delete the user, it do the same like i
want to show him and the view rended is the same of showing user :
http://localhost:3000/users/1
in the routes.rb there''s resources
:users
resources :user_admins, :only => [:index] do
collection do #operate on all ressources, not on a specific one
................................
...................................
end
end
what can i do to resolve this probleme please.
thanks
--
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.
its ok, i resolve it
this is what i did:
int the view:
<td><%= link_to ''Destroy'', :controller => :users,
:action
=> :destroy, :id => user %></td>
in the routes.rb:
resources :users, :only => [:destroy] do
collection do
get ''users'' => :destroy
end
end
resources :users
all works good :)
--
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.
http://localhost:3000/users/1 is the correct URL for deleting a user. However, it should be sent with a "method" of "delete" instead of "get". That''s what this snippet of code is for: method => :delete If it''s not working properly from your first example, you probably don''t have jQuery/Prototype UJS setup properly. Can you confirm that? It''s very bad form to have a "get" link delete an object in the database. What happens if a web crawler or bot clicks on all the links on your page? All your items will be deleted. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/scQFW09clm8J. 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.
ok i will test. thanks 2011/6/20 Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org>> http://localhost:3000/users/1 is the correct URL for deleting a user. > However, it should be sent with a "method" of "delete" instead of "get". > That''s what this snippet of code is for: > > method => :delete > > If it''s not working properly from your first example, you probably don''t > have jQuery/Prototype UJS setup properly. Can you confirm that? > > It''s very bad form to have a "get" link delete an object in the database. > What happens if a web crawler or bot clicks on all the links on your page? > All your items will be deleted. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/scQFW09clm8J. > > 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. >-- Mediouni Adel Tunis www.metal-tn.xooit.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.