11175
(-- --)
1
This is my index:
<td><%= link_to 'Remove', user,
:class => "list-actions", :confirm => 'Are you sure?',
:method => :delete %></td>
And this is my controller:
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
For some reason, when I click on the 'Remove' link, it directs me to the
'Show' action and does not destroy the item... strange ??
Thanks
Hi Justin,
Justin To wrote:
For some reason, <...>
The reason would be found in routes.rb. You can experiment, to good effect,
with script/console.
HTH,
Bill
Jeffrey
(Jeffrey)
3
Quoting Justin To <rails-mailing-list@andreas-s.net>:
This is my index:
<td><%= link_to 'Remove', user,
:class => "list-actions", :confirm => 'Are you sure?',
:method => :delete %></td>
And this is my controller:
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
For some reason, when I click on the 'Remove' link, it directs me to the
'Show' action and does not destroy the item... strange ??
The delete action/method does not invoke the destroy method. If you want
destroy, put it in the link. Unless you explicitly it in config/routes.rb.
HTH,
Jeffrey