From b4e338bf0f4853f39d393db9c903bc73f2f80e68 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 17 Feb 2013 15:10:58 -0500 Subject: [PATCH] fixes to tag search page --- app/controllers/pool_elements_controller.rb | 12 +++++++++--- app/controllers/tags_controller.rb | 2 +- app/models/tag.rb | 2 +- app/views/forum_topics/show.html.erb | 2 +- app/views/tags/search.html.erb | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/controllers/pool_elements_controller.rb b/app/controllers/pool_elements_controller.rb index 0bbbf66fc..f13eb161c 100644 --- a/app/controllers/pool_elements_controller.rb +++ b/app/controllers/pool_elements_controller.rb @@ -3,18 +3,24 @@ class PoolElementsController < ApplicationController before_filter :member_only def create - @pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id]) || Pool.create(:name => params[:pool_name], :description => "This pool was automatically generated") + @pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id]) + + if @pool.nil? + + return + end + @post = Post.find(params[:post_id]) @pool.add!(@post) append_pool_to_session(@pool) - respond_with(@pool, :location => pool_path(@pool)) + respond_with(@pool, :location => post_path(@post)) end def destroy @pool = Pool.find(params[:pool_id]) @post = Post.find(params[:post_id]) @pool.remove!(@post) - respond_with(@pool, :location => pool_path(@pool)) + respond_with(@pool, :location => post_path(@post)) end private diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 215baba8f..6738e5e2e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -14,7 +14,7 @@ class TagsController < ApplicationController end def search - @search = Tag.search(params[:search]) + # @search = Tag.search(params[:search]) end def show diff --git a/app/models/tag.rb b/app/models/tag.rb index 7d9ed82f5..a9d32cae6 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -393,7 +393,7 @@ class Tag < ActiveRecord::Base q = q.name_matches(params[:name_matches]) end - if params[:category] + if params[:category].present? q = q.where("category = ?", params[:category]) end diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index 17c016284..7a20001cb 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -17,7 +17,7 @@

<%= link_to "Reply »".html_safe, new_forum_post_path(:topic_id => @forum_topic.id) %>

-
+ diff --git a/app/views/tags/search.html.erb b/app/views/tags/search.html.erb index c53be075b..7cac02b88 100644 --- a/app/views/tags/search.html.erb +++ b/app/views/tags/search.html.erb @@ -5,7 +5,7 @@
- <%= select "search", "category", Danbooru.config.canonical_tag_category_mapping.to_a %> + <%= select "search", "category", [""] + Danbooru.config.canonical_tag_category_mapping.to_a %>
@@ -13,7 +13,7 @@ <%= select "search", "sort", %w(name count date) %>
- <%= f.button :submit, "Search" %> + <%= submit_tag "Search" %> <% end %>