Success message when using button_to_remote


In a partial I used button_to_remote for deleting record.

My record is deleted but message is not firing.

<%= button_to_remote "Delete", :url => {:controller => "users" , :action => "deletegroup", :group_name=>grouprow.group_name}, :class => "submit_input_button rounded_corner" %>

Action in Controller def deletegroup    j=0     puts "in delete group"    puts params[:group_name]    @grpfriends=

   @grp=Group.find_by_user_id_and_group_name( ,params[:group_name])    puts

@grpfriends=GroupFriend.find_all_by_group_id_and_user_id(,    puts @grpfriends

   @grpfriends.each do |f|    f.destroy    j=j+1    end


   @msg="Group deleted successfully."

   respond_to do |format|     flash[:error]=@errmsg     flash[:notice] = @msg     format.html {redirect_to :back}     end


Please help how I can display a success message "Group deleted successfully."

Thank you.

With a button_to_remote like that you're going to have to display the message yourself - either supply an onSuccess callback or write some rjs / call an rjs template ni your respond_to block that displays a message.