1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2025-12-10 08:46:41 +01:00

Merge pull request #8 from PFischbeck/problem_pagination

Problem pagination
This commit is contained in:
Philipp Fischbeck 2014-12-10 13:29:42 +01:00
commit 31e04d9511
7 changed files with 21 additions and 2 deletions

View File

@ -25,6 +25,9 @@ gem 'sdoc', '~> 0.4.0', group: :doc
gem 'twitter-bootstrap-rails'
gem 'will_paginate', '~> 3.0.6'
gem 'will_paginate-bootstrap'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

View File

@ -109,6 +109,9 @@ GEM
uglifier (2.5.3)
execjs (>= 0.3.0)
json (>= 1.8.0)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
PLATFORMS
x86-mingw32
@ -125,3 +128,5 @@ DEPENDENCIES
twitter-bootstrap-rails
tzinfo-data
uglifier (>= 1.3.0)
will_paginate (~> 3.0.6)
will_paginate-bootstrap

View File

@ -4,7 +4,7 @@ class ProblemsController < ApplicationController
# GET /problems
# GET /problems.json
def index
@problems = Problem.all
@problems = Problem.paginate(page: params[:page])
end
# GET /problems/1

View File

@ -1,4 +1,6 @@
class Problem < ActiveRecord::Base
validates :title, :content, presence: true
validates :title, uniqueness: true
self.per_page = 50
end

View File

@ -0,0 +1 @@
<%= will_paginate @problems, renderer: BootstrapPagination::Rails %>

View File

@ -1,5 +1,6 @@
<h1>Listing problems</h1>
<%= render 'problem_pagination' %>
<table class="table table-striped table-bordered">
<thead>
<tr>
@ -17,7 +18,7 @@
<% end %>
</tbody>
</table>
<%= render 'problem_pagination' %>
<br>
<%= link_to 'New Problem', new_problem_path, class: 'btn btn-default' %>

View File

@ -5,3 +5,10 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
for i in 1..103 do
Problem.create(
title: "Problem Nummer #{i}",
content: "Das hier ist der Inhalt von <b>Problem #{i}</b>.<br />Hier ist die zweite Zeile."
)
end