view:
<%= button_to 'Delete Friend', friendships_path(:friend_id => @user), method: 'delete', :form_class => 'delete_btn', remote: true %>
controller:
def destroy
@return = 'It works!'
render :json => ActiveSupport::JSON.encode( @return )
end
when i click the button i get a 404 page not found... how can i make the destroy method work for ajax jquery requests?
EDIT:
routes.rb
resources :friendships, :except => [:new, :edit, :update, :index, :show]
running rake:routes
friendships POST /friendships(.:format) friendships#create
friendship DELETE /friendships/:id(.:format) friendships#destroy
Replace:
friendships_path(:friend_id => @user)
With:
friendship_path(:id => @user)