Created
January 18, 2014 01:22
-
-
Save jacoyutorius/8484822 to your computer and use it in GitHub Desktop.
Sinatra+kaminariでPaginationしたい ref: http://qiita.com/jacoyutorius/items/5af67c298ea185f93dac
This file contains 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 characters
require “sinatra” | |
require “padrino-helpers” | |
require “kaminari/sinatra” | |
helpers Kaminari::Helpers::SinatraHelpers | |
get "/" do | |
array = [] | |
data.each do |row| | |
data = UserData.new | |
data = row["userid"] | |
data = row["count"] | |
array << data | |
end | |
@userdata = Kaminari.paginate_array(array).page(params[:page]).per(18) | |
erb :index | |
end |
This file contains 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 characters
bundle install --path .bundle |
This file contains 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 characters
bundle exec ruby app.rb |
This file contains 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 characters
gem "sinatra" | |
gem "sinatra-contrib" | |
gem "hashie" | |
gem "tilt", github: "rtomayko/tilt", tag: "1.3.4" | |
gem "kaminari", :require => "kaminari/sinatra" | |
gem "padrino-helpers" |
This file contains 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 characters
<%= paginate @userdata %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment