Reputation: 521
I have an app in rails 3 and i run the crud everything is working except the delete link.when i click it it always takes me to the show action and i want it to delete that particular record.below is the codes
VIEW
index.html.erb:
<td><%= link_to 'Destroy', member, :confirm => 'Are you sure?', :method =>:destroy %></td>
CONTROLLER
# DELETE /members/1
# DELETE /members/1.xml
def destroy
@member = Member.find(params[:id])
@member.destroy
respond_to do |format|
format.html { redirect_to(members_url) }
format.xml { head :ok }
end
end
...any help plz..
Upvotes: 1
Views: 214
Reputation: 15530
destroy is a controller's REST action
:method =>:delete not :method =>:destroy
Upvotes: 0
Reputation: 3773
Check the javascript libraries. in my application I had the same problem because I removed prototype and did not install jquery.
This problem occurs because the DELETE method is emulated via javascript.
Upvotes: 2