I have this:
<%= link_to 'Delete', post , method: :delete, data: { confirm: 'Are you sure?' } %>
After clicking, Rails deletes the current record post.
I want refresh current page after deleting.
At your controller
destroy method use the current page's url for redirect.
def destroy
@object.destroy
respond_to do |format|
format.html { redirect_to current_page_url, notice: 'page was successfully destroyed.' }
format.json { head :no_content }
end
end
in Rails 5 you can do:
redirect_back(fallback_location: root_path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With