[logaling-commit] logaling/logaling-server [enable-removing-user-glossary] Add interface of removing user glossary

Back to archive index

SUZUKI Miho null+****@clear*****
Thu Sep 27 15:30:36 JST 2012


SUZUKI Miho	2012-09-27 15:30:36 +0900 (Thu, 27 Sep 2012)

  New Revision: 98b8419c84bd3203fc11ea9ceaed3612f8e8f097
  https://github.com/logaling/logaling-server/commit/98b8419c84bd3203fc11ea9ceaed3612f8e8f097

  Log:
    Add interface of removing user glossary

  Modified files:
    app/controllers/user_glossaries_controller.rb
    app/views/dashboard/show.html.haml
    config/routes.rb

  Modified: app/controllers/user_glossaries_controller.rb (+11 -0)
===================================================================
--- app/controllers/user_glossaries_controller.rb    2012-09-27 14:58:22 +0900 (ce2ea52)
+++ app/controllers/user_glossaries_controller.rb    2012-09-27 15:30:36 +0900 (e6744bb)
@@ -26,4 +26,15 @@ class UserGlossariesController < ApplicationController
     @user_glossary.errors.add(:name, e) if @user_glossary.errors.empty?
     render action: "new"
   end
+
+  # DELETE /user_glossaries/1
+  def destroy
+    @user_glossary = UserGlossary.find(params[:id])
+    @user_glossary.destroy
+    redirect_to dashboard_path, notice: 'User glossary was successfully destroyed.'
+  rescue Logaling::CommandFailed, Logaling::GlossaryNotFound => e
+    redirect_to dashboard_path, notice: e.to_s
+  rescue ActiveRecord::RecordNotFound
+    render :file => 'public/404.html', :status => 404, :layout => false
+  end
 end

  Modified: app/views/dashboard/show.html.haml (+1 -2)
===================================================================
--- app/views/dashboard/show.html.haml    2012-09-27 14:58:22 +0900 (c680af0)
+++ app/views/dashboard/show.html.haml    2012-09-27 15:30:36 +0900 (de6b9fc)
@@ -24,8 +24,7 @@
             %i.icon-pencil
           %a.btn.btn-mini{ :href => '#', :title => '複製する' }
             %i.icon-plus
-          %a.btn.btn-mini{ :href => '#', :title => '削除する' }
-            %i.icon-trash
+          = link_to raw("<i class=icon-trash></i>"), user_glossary_path(current_user, user_glossary), method: :delete, :class => 'btn btn-mini'
 
   %h2
     参加しているGitHubプロジェクトの管理

  Modified: config/routes.rb (+1 -1)
===================================================================
--- config/routes.rb    2012-09-27 14:58:22 +0900 (e26f60b)
+++ config/routes.rb    2012-09-27 15:30:36 +0900 (5d29313)
@@ -17,7 +17,7 @@ LogalingServer::Application.routes.draw do
       :only => [:new, :create]
     resources :user_glossaries,
       :path => 'glossaries',
-      :only => [:new, :create, :show],
+      :only => [:new, :create, :show, :destroy],
       :as => :glossaries do
         resources :terms
     end
-------------- next part --------------
An HTML attachment was scrubbed...
Télécharger 



More information about the logaling-commit mailing list
Back to archive index