pagers 3.1.5 → 4.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +28 -15
  4. data/Rakefile +1 -16
  5. data/app/views/pagers/_main.html.erb +1 -1
  6. data/lib/generators/pagers/install/install_generator.rb +13 -0
  7. data/lib/generators/pagers/install/templates/initializer.rb +7 -0
  8. data/lib/pagers.rb +8 -13
  9. data/lib/pagers/configuration.rb +7 -0
  10. data/lib/pagers/extensions/action_view/base.rb +48 -0
  11. data/lib/pagers/extensions/active_record/base.rb +43 -0
  12. data/lib/pagers/extensions/active_record/relation.rb +43 -0
  13. data/lib/pagers/railtie.rb +7 -3
  14. data/lib/pagers/version.rb +1 -1
  15. data/test/dummy/Rakefile +1 -2
  16. data/test/dummy/app/assets/javascripts/application.js +2 -2
  17. data/test/dummy/app/assets/stylesheets/application.css +6 -4
  18. data/test/dummy/app/controllers/products_controller.rb +8 -0
  19. data/test/dummy/app/models/product.rb +2 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +9 -11
  21. data/test/dummy/app/views/products/index.html.erb +1 -0
  22. data/test/dummy/bin/bundle +1 -0
  23. data/test/dummy/bin/rails +2 -1
  24. data/test/dummy/bin/rake +1 -0
  25. data/test/dummy/bin/setup +30 -0
  26. data/test/dummy/config.ru +1 -1
  27. data/test/dummy/config/application.rb +3 -0
  28. data/test/dummy/config/boot.rb +1 -1
  29. data/test/dummy/config/database.yml +4 -22
  30. data/test/dummy/config/database.yml.travis +3 -0
  31. data/test/dummy/config/environment.rb +1 -1
  32. data/test/dummy/config/environments/development.rb +15 -3
  33. data/test/dummy/config/environments/production.rb +21 -26
  34. data/test/dummy/config/environments/test.rb +10 -12
  35. data/test/dummy/config/initializers/assets.rb +11 -0
  36. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  37. data/test/dummy/config/initializers/mime_types.rb +1 -2
  38. data/test/dummy/config/initializers/pagers.rb +7 -0
  39. data/test/dummy/config/initializers/session_store.rb +1 -1
  40. data/test/dummy/config/routes.rb +1 -0
  41. data/test/dummy/config/secrets.yml +22 -0
  42. data/test/dummy/db/migrate/20130820024335_create_products.rb +7 -0
  43. data/test/dummy/db/schema.rb +6 -4
  44. data/test/dummy/log/development.log +25 -0
  45. data/test/dummy/log/test.log +22127 -987
  46. data/test/dummy/public/404.html +58 -55
  47. data/test/dummy/public/422.html +58 -55
  48. data/test/dummy/public/500.html +57 -54
  49. data/test/dummy/tmp/cache/assets/sprockets/v3.0/34/34l0xNON3WYrRP9HWkz5ZK9IQzIEVGYFn6VDMKiheeA.cache +0 -0
  50. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
  51. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
  52. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache +1 -0
  53. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TO/TOCwj3wVkgMFleFRO8KMLE3Qq6FsXpCeZD56U1AEPEc.cache +0 -0
  54. data/test/dummy/tmp/cache/assets/sprockets/v3.0/YJ/YJjzVvL4dd5E1S5fIpCphDLf9mEWeGfhO-ALTZpJ8-c.cache +0 -0
  55. data/test/dummy/tmp/cache/{sprockets/v3.0/4qi4l6mZwh9hUfWOWITw6FuJ15NRpPcIgJ22C20Yrhw.cache → assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache} +0 -0
  56. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache +1 -0
  57. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
  58. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache +1 -0
  59. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache +1 -0
  60. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  61. data/test/dummy/tmp/cache/{sprockets/v3.0/IXhyhrFX9OAFbL6na95F8HncYlwJm9_DdZx3OGTlvjk.cache → assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache} +0 -0
  62. data/test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache +1 -0
  63. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache +1 -0
  64. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yH/yHjEG5b89-DY37A9c_d90xiOarCQ4bJHa-i98W72DXI.cache +0 -0
  65. data/test/generator_test.rb +5 -5
  66. data/test/relation_test.rb +85 -0
  67. data/test/test_helper.rb +6 -13
  68. data/test/view_test.rb +47 -0
  69. metadata +75 -96
  70. data/lib/generators/pagers/install_generator.rb +0 -13
  71. data/lib/generators/pagers/templates/pagers.rb +0 -2
  72. data/lib/pagers/action_view/base.rb +0 -40
  73. data/lib/pagers/active_record/base.rb +0 -37
  74. data/lib/pagers/active_record/relation.rb +0 -41
  75. data/test/dummy/README.rdoc +0 -28
  76. data/test/dummy/app/controllers/pages_controller.rb +0 -7
  77. data/test/dummy/app/models/record.rb +0 -2
  78. data/test/dummy/app/views/pages/index.html.erb +0 -1
  79. data/test/dummy/config/initializers/secret_token.rb +0 -13
  80. data/test/dummy/db/migrate/20130820024335_create_records.rb +0 -9
  81. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  87. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  88. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  89. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  90. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  91. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  92. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  93. data/test/dummy/tmp/cache/sprockets/v3.0/4CacREYU-WtfLMBbdP-dhQGvv5x5m64f08AyEfpJQOo.cache +0 -1
  94. data/test/dummy/tmp/cache/sprockets/v3.0/92EHsdop8I2qLLTnyIPHKsBjC79WjGLaG37jVJyQVhk.cache +0 -0
  95. data/test/dummy/tmp/cache/sprockets/v3.0/EWvcaZ9y1ATwOV77WPqF6MOVajQDzmhssysEljgt9Eo.cache +0 -0
  96. data/test/dummy/tmp/cache/sprockets/v3.0/Ko7VnYzTp2dC_WWnmGeCA4HQFz0DP4BhGt3lwlHhHi8.cache +0 -1
  97. data/test/dummy/tmp/cache/sprockets/v3.0/LhsrcVSJd1rOgmBlzouy8hNPVwxmPKoQ-Gas3gSxTkI.cache +0 -1
  98. data/test/dummy/tmp/cache/sprockets/v3.0/V69Dt-aUrVqv_nmsS1zbhdjuZiJYjFhnrydvD2K2GUM.cache +0 -0
  99. data/test/dummy/tmp/cache/sprockets/v3.0/_Ncty4f5wW4Cr2m5RgKKk4M1vjFREhRT4rNNa3xudJk.cache +0 -0
  100. data/test/dummy/tmp/cache/sprockets/v3.0/aN14MzsGXl0Y-OLjTiDPq1Q4JIyN7HL8WxyvnCmR15s.cache +0 -0
  101. data/test/dummy/tmp/cache/sprockets/v3.0/bK7xK7GDY9-6iymHURf47UyKHbhI_XkIoXheTZIkob8.cache +0 -1
  102. data/test/dummy/tmp/cache/sprockets/v3.0/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +0 -3
  103. data/test/dummy/tmp/cache/sprockets/v3.0/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +0 -2
  104. data/test/dummy/tmp/cache/sprockets/v3.0/pwlpdo053gu3Fg6oen1pnE9oV9ErbgrDW0VbKPLs098.cache +0 -0
  105. data/test/dummy/tmp/cache/sprockets/v3.0/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -3
  106. data/test/dummy/tmp/cache/sprockets/v3.0/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -2
  107. data/test/empty_test.rb +0 -39
  108. data/test/first_test.rb +0 -43
  109. data/test/last_test.rb +0 -43
  110. data/test/middle_test.rb +0 -43
  111. data/test/padding_test.rb +0 -21
  112. data/test/route_test.rb +0 -69
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e9f106db75e6002849694e8c7f2e2b814b9f063
4
- data.tar.gz: fa92f8db5081d4bda219dfcf771068ee23bf88cc
3
+ metadata.gz: dfb6743176da1df0ec2e6260bd613767dc1838a5
4
+ data.tar.gz: 0db4191a5adc4f890dbeaa45c2784d761ff9da4d
5
5
  SHA512:
6
- metadata.gz: 4595903a76bc0c878c00d3a4630787790f920e46a7c84bdc645f5e2e8f4d919f89b062eb8472b4d901546931ac8684b61ce3ce51a4e071989739d5e132f9dfc8
7
- data.tar.gz: 8487cd7c2b2b731683370a526cf5eae50982fc7731717bfb260350ece4bf095b0ebe53e05a04bd497e167704c8cf6b13da031c112149f7e48c59b22373a77e31
6
+ metadata.gz: 2f07d1fe0b714f634ee628e6a4857c8f54936979c527f44c18c0a3bd07b6a29f615511fdabbeff2286bbd8b78f12cb32212b9ff86f712f18db8f31dac57ca99c
7
+ data.tar.gz: 5e643b2c86deb135c728b16e459ac0c3d21471a4c26ecf27966b40c081a613d072cc3beca5c11530fc9cd9378e1023766383fa666479ad8ddbc4771ad720ae0d
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2015 Mathías Montossi
1
+ Copyright 2016 Mathías Montossi
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -5,7 +5,15 @@
5
5
 
6
6
  # Pagers
7
7
 
8
- Minimalistic pagers inspired in kaminari and will_paginate for rails.
8
+ Scope based pagination engine for rails.
9
+
10
+ ## Why
11
+
12
+ I did this gem to:
13
+
14
+ - Simplify code by keep close integration with rails.
15
+ - Have most common used settings set out of the box.
16
+ - Create a compatible pagination for [indexes gem](https://github.com/mmontossi/indexes).
9
17
 
10
18
  ## Install
11
19
 
@@ -23,48 +31,53 @@ $ bundle
23
31
 
24
32
  Generate the configuration file:
25
33
  ```
26
- rails g pagers:install
34
+ $ bundler exec rails g pagers:install
27
35
  ```
28
36
 
29
- The defaults values are:
37
+ Set the global settings:
30
38
  ```ruby
31
39
  Pagers.configure do |config|
40
+
32
41
  config.length = 20
33
42
  config.padding = 0
34
- config.parameter = :page
35
- config.pages = 5
43
+ config.links = 5
44
+
36
45
  end
37
46
  ```
38
47
 
39
48
  ## Usage
40
49
 
50
+ ### Relation
51
+
41
52
  Call the page scope from your models:
42
53
  ```ruby
43
- @collection = Model.page(1, length: 10, padding: 4)
54
+ @products = Product.page(1)
44
55
  ```
45
56
 
46
- And in your views just:
57
+ You can override global options by passing a hash:
58
+ ```ruby
59
+ @products = Product.page(1, length: 10, padding: 4)
60
+ ```
61
+
62
+ ### Views
63
+
64
+ You can use paginate helper to generate a pager html:
47
65
  ```erb
48
66
  <%= paginate @collection %>
49
67
  ```
50
68
 
51
- NOTE: You can override the parameters in the scope and in the helper.
52
-
53
- ## SEO
69
+ ### SEO
54
70
 
55
- You can add the parameter to paths:
71
+ If you want to remove the page query parameter, add an optional parameter to the route:
56
72
  ```ruby
57
73
  get 'search/:query/(:page)' => 'products#search'
58
74
  ```
59
75
 
60
- To produce routes like:
76
+ That will produce links like this:
61
77
  ```
62
78
  search/sample
63
79
  search/sample/2
64
80
  search/sample/3
65
- .
66
- .
67
- .
68
81
  ```
69
82
 
70
83
  ## Credits
data/Rakefile CHANGED
@@ -4,21 +4,6 @@ rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
6
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Pagers'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
- load 'rails/tasks/engine.rake'
19
-
20
-
21
-
22
7
  Bundler::GemHelper.install_tasks
23
8
 
24
9
  require 'rake/testtask'
@@ -28,7 +13,7 @@ Rake::TestTask.new(:test) do |t|
28
13
  t.libs << 'test'
29
14
  t.pattern = 'test/**/*_test.rb'
30
15
  t.verbose = false
16
+ t.warning = false
31
17
  end
32
18
 
33
-
34
19
  task default: :test
@@ -19,7 +19,7 @@
19
19
  link_to(
20
20
  page,
21
21
  page_path(page, options),
22
- rel: (collection.next_page == page ? 'next' : collection.previous_page == page ? 'prev' : nil)
22
+ rel: (collection.next_page == page ? 'next' : (collection.previous_page == page ? 'prev' : nil))
23
23
  )
24
24
  %>
25
25
  </li>
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Pagers
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def create_initializer_file
9
+ copy_file 'initializer.rb', 'config/initializers/pagers.rb'
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ Pagers.configure do |config|
2
+
3
+ config.length = 20
4
+ config.padding = 0
5
+ config.links = 5
6
+
7
+ end
data/lib/pagers.rb CHANGED
@@ -1,25 +1,20 @@
1
- require 'pagers/action_view/base'
2
- require 'pagers/active_record/base'
3
- require 'pagers/active_record/relation'
1
+ require 'pagers/extensions/action_view/base'
2
+ require 'pagers/extensions/active_record/base'
3
+ require 'pagers/extensions/active_record/relation'
4
+ require 'pagers/configuration'
4
5
  require 'pagers/engine'
5
6
  require 'pagers/railtie'
7
+ require 'pagers/version'
6
8
 
7
9
  module Pagers
8
10
  class << self
9
11
 
10
12
  def configure
11
- yield config
13
+ yield configuration
12
14
  end
13
15
 
14
- def config
15
- @config ||= begin
16
- ActiveSupport::OrderedOptions.new.tap do |config|
17
- config.length = 20
18
- config.padding = 0
19
- config.parameter = :page
20
- config.pages = 5
21
- end
22
- end
16
+ def configuration
17
+ @configuration ||= Configuration.new
23
18
  end
24
19
 
25
20
  end
@@ -0,0 +1,7 @@
1
+ module Pagers
2
+ class Configuration
3
+
4
+ attr_accessor :length, :padding, :links
5
+
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ module Pagers
2
+ module Extensions
3
+ module ActionView
4
+ module Base
5
+ extend ActiveSupport::Concern
6
+
7
+ def page_path(number, options={})
8
+ if number == 1
9
+ number = nil
10
+ end
11
+ url_for request.query_parameters.merge(page: number)
12
+ end
13
+
14
+ def paginate(collection, options={})
15
+ links = (options[:links] || Pagers.configuration.links)
16
+ if collection.total_pages >= links
17
+ middle = (links / 2).ceil
18
+ if collection.current_page > (collection.total_pages - middle)
19
+ starts_at = (collection.total_pages - links + 1)
20
+ ends_at = collection.total_pages
21
+ elsif collection.current_page <= middle
22
+ starts_at = 1
23
+ ends_at = links
24
+ else
25
+ starts_at = (collection.current_page - middle)
26
+ ends_at = (collection.current_page + middle)
27
+ end
28
+ else
29
+ starts_at = 1
30
+ ends_at = collection.total_pages
31
+ end
32
+ pages = Range.new(starts_at, ends_at)
33
+ less_pages = (starts_at > 1)
34
+ more_pages = (ends_at < collection.total_pages)
35
+ render(
36
+ 'pagers/main',
37
+ collection: collection,
38
+ pages: pages,
39
+ less_pages: less_pages,
40
+ more_pages: more_pages,
41
+ options: options
42
+ )
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ module Pagers
2
+ module Extensions
3
+ module ActiveRecord
4
+ module Base
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+
9
+ def inherited(subclass)
10
+ subclass.class_eval do
11
+ if superclass == ::ActiveRecord::Base
12
+ scope :page, ->(number, options={}) {
13
+ padding = (options[:padding] || Pagers.configuration.padding)
14
+ length = (options[:length] || Pagers.configuration.length)
15
+ current_page = [number.to_i, 1].max
16
+ limit = length
17
+ offset = ((length * (current_page - 1)) + padding)
18
+ values = Module.new do
19
+ define_method :padding do
20
+ padding
21
+ end
22
+ define_method :page_length do
23
+ length
24
+ end
25
+ define_method :current_page do
26
+ current_page
27
+ end
28
+ end
29
+ limit(limit).offset(offset).extending(
30
+ Pagers::Extensions::ActiveRecord::Relation,
31
+ values
32
+ )
33
+ }
34
+ end
35
+ end
36
+ super
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ module Pagers
2
+ module Extensions
3
+ module ActiveRecord
4
+ module Relation
5
+ extend ActiveSupport::Concern
6
+
7
+ def total_pages
8
+ @total_pages ||= [(total_count.to_f / page_length).ceil, 1].max
9
+ end
10
+
11
+ def previous_page
12
+ @previous_page ||= (current_page > 1 ? (current_page - 1) : nil)
13
+ end
14
+
15
+ def next_page
16
+ @next_page ||= (current_page < total_pages ? (current_page + 1) : nil)
17
+ end
18
+
19
+ def first_page
20
+ 1
21
+ end
22
+
23
+ def last_page
24
+ total_pages
25
+ end
26
+
27
+ def out_of_bounds?
28
+ @out_of_bounds ||= (current_page > total_pages || current_page < first_page)
29
+ end
30
+
31
+ def total_count
32
+ @total_count ||= begin
33
+ r = except(:limit, :offset, :order)
34
+ r = r.except(:includes) unless references_eager_loaded_tables?
35
+ r = r.count
36
+ (r.respond_to?(:count) ? r.count : r) - padding
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,9 +1,13 @@
1
1
  module Pagers
2
2
  class Railtie < Rails::Railtie
3
3
 
4
- initializer 'pagers' do
5
- ::ActiveRecord::Base.send :include, Pagers::ActiveRecord::Base
6
- ::ActionView::Base.send :include, Pagers::ActionView::Base
4
+ initializer 'pagers.extensions' do
5
+ ::ActiveRecord::Base.include(
6
+ Pagers::Extensions::ActiveRecord::Base
7
+ )
8
+ ::ActionView::Base.include(
9
+ Pagers::Extensions::ActionView::Base
10
+ )
7
11
  end
8
12
 
9
13
  end
@@ -1,5 +1,5 @@
1
1
  module Pagers
2
2
 
3
- VERSION = '3.1.5'
3
+ VERSION = '4.0.0.0'
4
4
 
5
5
  end
data/test/dummy/Rakefile CHANGED
@@ -2,5 +2,4 @@
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
4
  require File.expand_path('../config/application', __FILE__)
5
-
6
- Dummy::Application.load_tasks
5
+ Rails.application.load_tasks
@@ -2,12 +2,12 @@
2
2
  // listed below.
3
3
  //
4
4
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
8
  // compiled file.
9
9
  //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
13
  //= require_tree .
@@ -3,11 +3,13 @@
3
3
  * listed below.
4
4
  *
5
5
  * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
10
12
  *
11
- *= require_self
12
13
  *= require_tree .
14
+ *= require_self
13
15
  */
@@ -0,0 +1,8 @@
1
+ class ProductsController < ApplicationController
2
+
3
+ def index
4
+ number = (params[:page] || 1)
5
+ @products = Product.page(number, length: 1)
6
+ end
7
+
8
+ end
@@ -0,0 +1,2 @@
1
+ class Product < ActiveRecord::Base
2
+ end
@@ -1,14 +1,12 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
- <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <%= yield %>
11
+ </body>
14
12
  </html>