I've followed all the instructions from
http://guides.rubyonrails.org/getting_started.html and I've a blog set up, that has a form, allows a user to create a post, comment, edit, add tags, has some security to protect who can post,and edit, delete etc. Only problem is that when I click delete post, I get the expected message "are you sure?" with the option to continue or to cancel. However when I click cancel it goes ahead and deletes the comment anyway. So I'm trying to find out how I can fix this.
In the views post index there is the line
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %>
In the controllers (which I suspect is where I have to change something) I have this code
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(posts_url) }
format.xml { head :ok }
end
I've had a look around to find the code for the form_for method and I can't find it. Perhaps that's where I should be looking?
Spread The Love, Share Our Article
1 Response to Destroy - Ruby Blog
I found the answer to this here http://stackoverflow.com/questions/3772450/rails-3-method-delete-doesnt-work-in-internet-explorer
The Javascript that comes bundled with Rails 3 doesn't work too well with Internet Explorer. So I replaced the code in the public/Javascripts/rails.js file with the code found here..https://github.com/rails/prototype-ujs/raw/master/src/rails.js and now it works just fine.
Post a Comment