about summary refs log tree commit diff stats
path: root/app/controllers/quotes_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/quotes_controller.rb')
-rw-r--r--app/controllers/quotes_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index d4800cb..468f6ea 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb
@@ -30,6 +30,20 @@ class QuotesController < ApplicationController
30 end 30 end
31 end 31 end
32 32
33 def search_form
34 @q = Quote.published.ransack
35 end
36
37 def search
38 @quotes = Quote.published.ransack(params[:q]).result(distinct: true).paginate(page: params[:page], per_page: 10)
39
40 respond_to do |format|
41 format.html { render :list }
42 format.json { render :json => @quotes }
43 format.xml { render :xml => @quotes }
44 end
45 end
46
33 def random 47 def random
34 picked = Quote.where(state: :published).ids.sample 48 picked = Quote.where(state: :published).ids.sample
35 redirect_to quote_url(picked) 49 redirect_to quote_url(picked)