some random patches that might improve things slightly (yes I still use substruct! 2010 projects live on! :)
maybe a 303 redir is more appropriate here?
diff --git a/app/controllers/music_controller.rb b/app/controllers/music_controller.rb
index 198d9e4..122ad2e 100644
--- a/app/controllers/music_controller.rb
+++ b/app/controllers/music_controller.rb
@@ -37,8 +37,8 @@ class MusicController < StoreController
@product = Product.find_by_code(params[:id], :include => [:images, :downloads, {:tags => [:parent]}])
if !@product
- flash[:notice] = "Sorry, we couldn't find the song you were looking for"
- redirect_to :action => 'index' and return false
+ flash[:notice] = "Sorry, we couldn't find the song you were looking for " + params[:id].to_s
+ redirect_to :action => 'index', :status => 303 and return false # 303 is not found
end
if not_a_bot
# avoid after_save blocks ...
diff --git a/app/controllers/music_controller.rb b/app/controllers/music_controller.rb
index 66a23a5..5e251ce 100644
--- a/app/controllers/music_controller.rb
+++ b/app/controllers/music_controller.rb
@@ -295,6 +295,7 @@ class MusicController < StoreController
# If only one product comes back, take em directly to it.
session[:last_search] = @search_term
if @products.size == 1
+ flash[:notice] = 'Found one song that matches...'
redirect_to :action => 'show', :id => @products[0].code and return
else
render :action => 'index.rhtml'
also perhaps searching should search description text as well?
here's one, accomodate for empty search string:
def search
@search_term = params[:search_term]
+ unless @search_term
+ render(:file => "#{RAILS_ROOT}/public/404.html", :status => 404) and return
+ end
@title = "Search Results for: #{@search_term}"
super_search_terms = params[:search_term].split.map{|name| name.gsub(/[^a-z]/, '')}.map{|name| ["%#{name}%"]*2}.f
show last search in the top box:
diff --git a/app/controllers/music_controller.rb b/app/controllers/music_controller.rb
index d005019..308397f 100644
--- a/app/controllers/music_controller.rb
+++ b/app/controllers/music_controller.rb
@@ -290,6 +290,7 @@ class MusicController < StoreController
end
# If only one product comes back, take em directly to it.
+ session[:last_search] = @search_term
if @products.size == 1
redirect_to :action => 'show', :id => @products[0].code and return
else
diff --git a/app/views/_main_yes_no_box.rhtml b/app/views/_main_yes_no_box.rhtml
index 5e7a016..3923e2e 100644
--- a/app/views/_main_yes_no_box.rhtml
+++ b/app/views/_main_yes_no_box.rhtml
@@ -86,7 +86,7 @@
<div id="searchbox" style="width: 350px;">
<form action="/music/search" method="get">
<input type="image" src="/plugin_assets/substruct/images/public-ui/buttons/search.gif"
- <input type="text" name="search_term" class="textInput big" value="<%= @search_term %>
+ <input type="text" name="search_term" class="textInput big" value="<%= session.delete(
</form>
<div style="float: right; margin-top: 10px; margin-right: 60px;">
<a href="/music/advanced_search">Advanced search</a><span style="color: grey; font-size:
and here's (I'm unsure how far I got on this) some 1.9 compat patches (I still run on REE today though).
https://gist.github.com/rdp/9547906Anyway thank you for substruct, it actually made my rails projects possible, instead of awful.
-roger-