diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-04 22:47:31 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-03-04 22:47:31 -0500 |
commit | f3e3735c7efe9ba8fcc0e58cda4ee3996e12d38e (patch) | |
tree | d1913cb1ff747d9202ff9efb34a4e12c982163b6 /app/controllers | |
parent | 49c58dc5de3688d842025b83cbc91a69ef621641 (diff) | |
download | thoughts-f3e3735c7efe9ba8fcc0e58cda4ee3996e12d38e.tar.gz thoughts-f3e3735c7efe9ba8fcc0e58cda4ee3996e12d38e.tar.bz2 thoughts-f3e3735c7efe9ba8fcc0e58cda4ee3996e12d38e.zip |
Add quotes search
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/quotes_controller.rb | 14 |
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) |