Skip to content
This repository
Browse code

pagination fixes and better validation of single-quotes

  • Loading branch information...
commit edab7bb6364501a81192a651a09e2d82e1ead069 1 parent 3e4f91d
Jeffrey Warren authored March 19, 2012
1  webserver/app/controllers/spectrums_controller.rb
@@ -62,6 +62,7 @@ def compare
62 62
   def search
63 63
     params[:id] = params[:q]
64 64
     @spectrums = Spectrum.find(:all, :conditions => ['title LIKE ? OR notes LIKE ?',"%"+params[:id]+"%", "%"+params[:id]+"%"],:limit => 100)
  65
+    @spectrums = @spectrums.paginate :page => params[:page], :per_page => 24
65 66
   end
66 67
 
67 68
   # non REST
2  webserver/app/models/spectrum.rb
@@ -4,7 +4,7 @@ class Spectrum < ActiveRecord::Base
4 4
 	validates_presence_of :author, :on => :create, :message => "can't be blank"
5 5
 	validates_presence_of :photo, :on => :create, :message => "can't be blank"
6 6
 	validates_length_of :title, :maximum=>60
7  
-        validates_format_of :title, :with => /\A[a-zA-Z0-9\' -_]+\z/, :message => "Only letters, numbers, and spaces allowed" 
  7
+        validates_format_of :title, :with => /\A[a-zA-Z0-9\ -_]+\z/, :message => "Only letters, numbers, and spaces allowed" 
8 8
         validates_format_of :author, :with => /\A[a-zA-Z0-9_]+\z/, :message => "Only letters and numbers allowed" 
9 9
 
10 10
 	has_many :comments, :dependent => :destroy
2  webserver/app/views/spectrums/_sidebar.html.erb
@@ -3,7 +3,7 @@
3 3
 		<a href="/spectrums/new" class="button">Upload a spectrum &raquo;</a>
4 4
 	</p>
5 5
 	<div class="box search">
6  
-		<form action="/spectrums/search" method='get'>
  6
+		<form action="/spectra/search" method='get'>
7 7
 			<input class='text' type='text' name='q' value='<%= params[:id] %>'/>
8 8
 			<input type='submit' value='search' />
9 9
 		</form>
2  webserver/config/routes.rb
@@ -9,6 +9,8 @@
9 9
   map.resources :comments, :belongs_to => :spectrums
10 10
 
11 11
   map.connect 'spectra/feed', :controller => "spectrums", :action => "rss"
  12
+  map.connect 'spectra/search', :controller => "spectrums", :action => "search"
  13
+  map.connect 'spectra/search/:id', :controller => "spectrums", :action => "search"
12 14
   map.connect 'spectra/plotsfeed', :controller => "spectrums", :action => "plots_rss"
13 15
   map.connect 'spectra/feed/:author', :controller => "spectrums", :action => "rss"
14 16
   map.connect 'spectra/:id', :controller => "spectrums", :action => "show"

0 notes on commit edab7bb

Please sign in to comment.
Something went wrong with that request. Please try again.