diff options
| author | mo khan <mo@mokhan.ca> | 2014-10-19 09:52:12 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-10-19 09:52:12 -0600 |
| commit | bd053ea6aebfe1ca2b5348217ee5876ff7e80118 (patch) | |
| tree | c4a235f23198dfea6465ddf9d938a022b0b39b05 | |
| parent | 6fda7ad141fdf0129c57b30340c043b7e15167a9 (diff) | |
tie current category, sort to search.
| -rw-r--r-- | app/models/creation/repository.rb | 2 | ||||
| -rw-r--r-- | app/views/admin/users/index.html.erb | 4 | ||||
| -rw-r--r-- | app/views/cakes/_index.html.erb | 2 | ||||
| -rw-r--r-- | app/views/cakes/index.html.erb | 4 | ||||
| -rw-r--r-- | app/views/cakes/index.js.erb | 2 | ||||
| -rw-r--r-- | config/routes.rb | 2 |
6 files changed, 7 insertions, 9 deletions
diff --git a/app/models/creation/repository.rb b/app/models/creation/repository.rb index 5948d41f..8d93ebd8 100644 --- a/app/models/creation/repository.rb +++ b/app/models/creation/repository.rb @@ -2,7 +2,7 @@ class Creation include Queryable scope :tagged, ->(tag) { tagged_with([tag]).where('photos_count > 0') } scope :published, ->() { unscoped.distinct.includes(:user, :photos).joins(:photos).where('photos.image_processing' => nil) } - scope :search, ->(query) { where(["upper(creations.name) like :query OR upper(creations.story) like :query", { query: "%#{query.upcase}%" }]) } + scope :search, ->(query) { where(["UPPER(creations.name) LIKE :query OR UPPER(creations.story) LIKE :query", { query: "%#{query.upcase}%" }]) } class Repository < SimpleDelegator def initialize(connection = Creation) diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 512088db..e68f6314 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,12 +1,10 @@ +<%= provide(:search_path, admin_users_path) %> <div class="row-fluid"> <div class="span2"> <%= render partial: "my/shared/my_nav" %> </div> <div class="span10"> <h1>Users <small>(<%= @users.count %>)</small></h1> - <%= form_tag admin_users_path, method: :get, name: "search", remote: true do %> - <%= text_field_tag :q, params[:q], class: "search-query", placeholder: "Search" %> - <% end %> <div id="results-container"> <%= render partial: "index" %> </div> diff --git a/app/views/cakes/_index.html.erb b/app/views/cakes/_index.html.erb index 333ca4ea..0677679f 100644 --- a/app/views/cakes/_index.html.erb +++ b/app/views/cakes/_index.html.erb @@ -20,5 +20,5 @@ <% end %> </div> <div id='more-button-row' class="row-fluid"> - <%= link_to_next_page @creations, 'More...', params: { cache: false }, remote: true, class: 'btn pull-right more-button hidden', data: { disable_with: 'loading...' } %> + <%= link_to_next_page @creations, 'More...', params: { cache: false, sort: params[:sort], q: params[:q] }, remote: true, class: 'btn pull-right more-button hidden', data: { disable_with: 'loading...' } %> </div> diff --git a/app/views/cakes/index.html.erb b/app/views/cakes/index.html.erb index bb83f259..590ab5b1 100644 --- a/app/views/cakes/index.html.erb +++ b/app/views/cakes/index.html.erb @@ -20,8 +20,8 @@ <div id="bakery"> <div class="row-fluid"> <ul class="nav nav-tabs"> - <li class="<%= params[:sort].blank? || params[:sort] == "newest" ? "active" : "" %>"><%= link_to "Newest", newest_cakes_path %></li> - <li class="<%= params[:sort] == "oldest" ? "active" : "" %>"><%= link_to "Oldest", oldest_cakes_path %></li> + <li class="<%= params[:sort] == "oldest" ? "active" : "" %> pull-right"><%= link_to "Oldest", url_for(params.merge(sort: "oldest")) %></li> + <li class="<%= params[:sort].blank? || params[:sort] == "newest" ? "active" : "" %> pull-right"><%= link_to "Newest", url_for(params.merge(sort: "newest")) %></li> </ul> </div> <%= render partial: 'index' %> diff --git a/app/views/cakes/index.js.erb b/app/views/cakes/index.js.erb index fb0bc738..6844a663 100644 --- a/app/views/cakes/index.js.erb +++ b/app/views/cakes/index.js.erb @@ -1,3 +1,3 @@ $('#more-button-row').remove(); $('#pagination-row').remove(); -$('#bakery').append('<%= j render partial: 'index' %>'); +$('#bakery').append('<%= escape_javascript(render partial: 'index') %>'); diff --git a/config/routes.rb b/config/routes.rb index 30372d18..f0014843 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ Cake::Application.routes.draw do resources :cakes, only: [:index, :show], path: :cakes do resources :photos, only: [:index, :show] resources :favorites, :only => [:index, :create] - get 'page/:page', :action => :index, :on => :collection, as: :paginate + get 'page/:page', action: :index, on: :collection, as: :paginate collection do get :newest, action: 'index', sort: 'newest' get :oldest, action: 'index', sort: 'oldest' |
