app/controllers/collections_controller.rb in iqvoc-4.1.3 vs app/controllers/collections_controller.rb in iqvoc-4.2.0

- old
+ new

@@ -53,13 +53,11 @@ end end end def show - @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last - raise ActiveRecord::RecordNotFound.new("Could not find Collection for id '#{params[:id]}'") unless @collection - + @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last! authorize! :read, @collection # When in single query mode, AR handles ALL includes to be loaded by that # one query. We don't want that! So let's do it manually :-) ActiveRecord::Associations::Preloader.new(@collection, @@ -87,13 +85,11 @@ render :new end end def edit - @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last - raise ActiveRecord::RecordNotFound.new("Could not find Collection for id '#{params[:id]}'") unless @collection - + @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last! authorize! :update, @collection # When in single query mode, AR handles ALL includes to be loaded by that # one query. We don't want that! So let's do it manually :-) ActiveRecord::Associations::Preloader.new(@collection, [ @@ -102,13 +98,11 @@ build_note_relations end def update - @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last - raise ActiveRecord::RecordNotFound.new("Could not find Collection for id '#{params[:id]}'") unless @collection - + @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last! authorize! :update, @collection if @collection.update_attributes(params[:concept]) flash[:success] = I18n.t("txt.controllers.collections.save.success") redirect_to collection_path(:id => @collection) @@ -117,12 +111,10 @@ render :edit end end def destroy - @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last - raise ActiveRecord::RecordNotFound.new("Could not find Collection for id '#{params[:id]}'") unless @collection - + @collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last! authorize! :destroy, @collection if @collection.destroy flash[:success] = I18n.t("txt.controllers.collections.destroy.success") redirect_to collections_path