-
-
Save lunalium/67ec249af060627fce8a to your computer and use it in GitHub Desktop.
Revisions
-
mharris717 revised this gist
Aug 19, 2013 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ ruby '1.9.3' source 'https://rubygems.org' gem 'rails', '3.2.13' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem 'pg' gem 'active_model_serializers' gem 'will_paginate' -
mharris717 revised this gist
Aug 19, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ Minimal Paginaton Example (Rails + Ember) -
mharris717 revised this gist
Aug 19, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ {{#each post in controller}} {{render post post}} {{/each}} <a href="#" {{action showMore}}>Show More</a><br> -
mharris717 revised this gist
Aug 19, 2013 . 2 changed files with 6 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ class PostsController < ApplicationController def index @posts = Post.all.paginate(:page => (params[:page] || 1), :per_page => 5) render :json => @posts, :meta => {:total_pages => collection.total_pages, :page => (params[:page] || 1).to_i} end end -
mharris717 revised this gist
Aug 19, 2013 . 3 changed files with 38 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ App.Store = DS.Store.extend revision: 11 adapter: 'Em.PaginationAdapter' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ DS.Model.reopenClass loadMore: -> page = DS.defaultStore.typeMapFor(@).metadata.page + 1 @find(page: page) Em.ArrayController.reopen modelClass: -> @$firstObject.constructor showMore: -> @modelClass().loadMore() serializer = DS.RESTSerializer.create() Em.PaginationAdapter = DS.RESTAdapter.reopen serializer: serializer serializer.configure total: 'total' last_dt: 'last_dt' total_pages: 'total_pages' page: 'page' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ module PaginationControllerMod def collection #super.paginate(:page => (params[:page] || 1), :per_page => 1) @coll ||= end_of_association_chain.paginate(:page => (params[:page] || 1), :per_page => 5) end def index render :json => collection end def default_serializer_options {:meta => {:total_pages => collection.total_pages, :page => (params[:page] || 1).to_i}} end end -
mharris717 created this gist
Aug 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Stuff