My respond_to
block does not redirect back to the '/dashboard' view (url stays at 'gcal_user.19') and results in a "406 Not Acceptable" error when I click on the delete link in the dashboard view. Tried debugging, googling, stack overflow but all efforts been fruitless.
Using Rails 3.2.13, Ruby 1.9.3
The app includes jquery and jquery_ujs (unobtrusive js) in application.js
Dashboard View (Haml):
%div.control-group.controls
= link_to "Delete Gcal User", @gcal_user, method: :delete
GcalUser Controller:
def destroy
@gcal_user = current_user.gcal_user
# -- commented out for debugging --
# if @gcal_user.delete
# flash[:notice] = "#{@gcal_user.username} deleted"
# end
respond_to do |format|
format.html { redirect_to user_root_path }
end
end
config/routes.rb
get "home/index"
root :to => 'home#index' #, as: '/'
devise_for :users
resource :gcal_user
match "dashboard" => 'home#dashboard', as: :user_root
Route:
DELETE /gcal_user(.:format) gcal_users#destroy
Clicking on the Delete link correctly reaches the destroy
method. The issue occurs with the respond_to
block.
Other code samples seem to have this working... I can't figure out what I'm missing. Any ideas?
Second, the 406 error is due to a request type mismatch, I believe, how do I check the type of the request and response being generated? If there is a mismatch, where in the code would I be able to change the request type?