def destroy
@story = Story.edit(params[:id], @author)
- Story.transaction do
- @story.destroy_and_shorten
- end
respond_to do |format|
- format.html { redirect_to story_path(@story.comic) }
- format.json { head :ok }
+ if @story.destroy_and_shorten
+ flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
+ format.html { redirect_to :controller => 'stories', :action => :comic, :id => @story.comic_id }
+ format.json { head :ok }
+ else
+ flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
+ format.html { redirect_to story_path(@story) }
+ format.json { render json: @story.errors, status: :unprocessable_entity }
+ end
end
end
end