Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pagination fixes and better validation of single-quotes

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