javascript - Odd behaviour when attempting to delete/destroy a user -
i'm coming across odd behaviour when seek delete user project in rails.
briefly, have link in view allows admin user delete user:
<%= link_to 'delete user', user, :method => :delete, :confirm => "are sure?" %>
and here code in user controller:
# delete /users/1 # delete /users/1.json def destroy @user = user.find(params[:id]) @user.destroy respond_to |format| format.html { redirect_to users_url } format.json { head :no_content } end end
however, while user deleted, popup "are sure?" box appears twice, , next error appears:
activerecord::recordnotfound in userscontroller#destroy couldn't find user id=xxx
where "xxx" user id has been deleted.
doing bit of searching, people have suggested way javascript loaded in project, , perchance conflict jquery (i using jquery-rails
gem). however, application.html.erb
file seems fine:
<%= stylesheet_link_tag "application","http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" %> <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %>
as application.js file:
//= require jquery //= require jquery_ujs //= require jquery-ui //= require_tree .
so, i'm not sure why happening - first time i've encountered error.
anyone point me in right direction?
thanks!
you have 1 of library loading jquery twice. happened me before, think activeadmin @ time had different jquery dependency , jquery loaded twice , doubled calls.
your user error because user has been deleted sec time, can't find it.
javascript jquery ruby-on-rails
No comments:
Post a Comment