Skip to content

Commit

Permalink
Added is_primary to locations serializer, reset kaminari page to 1 if…
Browse files Browse the repository at this point in the history
… < max count per page
  • Loading branch information
Matt Burch committed May 3, 2019
1 parent 03183e1 commit 8709a0b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/blog_posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class BlogPostsController < ApplicationController

def index
@blog_posts = Kaminari.paginate_array(policy_scope(filter_blog_posts))
params[:page] = 1 if @blog_posts.count < Kaminari.config.default_per_page
@blog_posts = @blog_posts.page(params[:page])
.per(params[:per_page])
end
Expand Down Expand Up @@ -43,7 +44,6 @@ def filter_blog_posts
if params[:filter] == 'front page' || params[:filter] == 'featured'
blog_posts = blog_posts.tagged_with(params[:filter])
end

blog_posts
end
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def index
else
Kaminari.paginate_array(policy_scope(Event))
end
params[:page] = 1 if @events.count < Kaminari.config.default_per_page
@events = @events.page(params[:page])
.per(params[:per_page])
end
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/locations_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class LocationsSerializer < ActiveModel::Serializer
attributes :id, :active, :admin_emails, :alternate_name, :coordinates,
:description, :latitude, :longitude, :name, :short_desc, :slug,
:website, :updated_at, :url
:website, :updated_at, :url, :is_primary

has_one :address
has_one :organization, serializer: LocationsOrganizationSerializer
Expand Down

0 comments on commit 8709a0b

Please sign in to comment.