Better error when trying to add to nonexistent pool

fixes #2546
This commit is contained in:
Toks
2015-11-03 23:31:19 -05:00
parent 6514265ca7
commit bf182cb652
3 changed files with 9 additions and 4 deletions

View File

@@ -5,13 +5,13 @@ class PoolElementsController < ApplicationController
def create
@pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id])
if @pool.present?
if @pool.present? && !@pool.is_deleted?
@post = Post.find(params[:post_id])
@pool.add!(@post)
append_pool_to_session(@pool)
else
@error = "That pool does not exist"
end
respond_with(@pool, :location => post_path(@post))
end
def destroy

View File

@@ -1,4 +1,4 @@
<%= form_tag(pool_element_path, :class => "simple_form") do %>
<%= form_tag(pool_element_path, :class => "simple_form", :remote => true, :format => :js) do %>
<%= hidden_field_tag "post_id", @post.id %>
<div class="input">

View File

@@ -0,0 +1,5 @@
<% if @error %>
Danbooru.error("<%= j @error.to_s %>");
<% else %>
location.reload();
<% end %>