SHIMADA Koji
null+****@clear*****
Wed Sep 19 20:13:37 JST 2012
SHIMADA Koji 2012-09-19 20:13:37 +0900 (Wed, 19 Sep 2012) New Revision: e0c70386c5776aa9b823344df5cfd5c6725e932a https://github.com/logaling/logaling-server/commit/e0c70386c5776aa9b823344df5cfd5c6725e932a Log: Add set_user_glossary to before filter for TermsController Modified files: app/controllers/terms_controller.rb Modified: app/controllers/terms_controller.rb (+11 -4) =================================================================== --- app/controllers/terms_controller.rb 2012-09-19 20:12:53 +0900 (4ad0a05) +++ app/controllers/terms_controller.rb 2012-09-19 20:13:37 +0900 (09d37f0) @@ -1,16 +1,16 @@ #coding: utf-8 class TermsController < ApplicationController + before_filter :set_user_glossary + def new @term = Term.new end def create @term = Term.new(params[:term]) + @user_glossary.add!(@term) - user_glossary = UserGlossary.find(params[:glossary_id]) - user_glossary.add!(@term) - - redirect_to user_glossary_path(current_user, user_glossary), notice: 'Term was successfully added.' + redirect_to user_glossary_path(current_user, @user_glossary), notice: 'Term was successfully added.' rescue => e @term.errors.add(:source_term, e) if****@term*****? render action: "new" @@ -24,4 +24,11 @@ class TermsController < ApplicationController def destroy end + + private + def set_user_glossary + @user_glossary = UserGlossary.find(params[:glossary_id]) + rescue ActiveRecord::RecordNotFound + render :file => 'public/404.html', :status => 404, :layout => false + end end -------------- next part -------------- An HTML attachment was scrubbed... Download