diff --git a/.gitignore b/.gitignore index f22dd347..7a80b93d 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ /yarn-error.log yarn-debug.log* .yarn-integrity + +.idea/ \ No newline at end of file diff --git a/Gemfile b/Gemfile index d84f4986..737c7ea3 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem "webpacker", "~> 5.0" gem "turbolinks", "~> 5" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem "jbuilder", "~> 2.7" +gem "kaminari" gem "pry" # Use Redis adapter to run Action Cable in production # gem "redis", "~> 4.0" diff --git a/Gemfile.lock b/Gemfile.lock index 72c4162f..0f8e8b89 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -92,6 +92,18 @@ GEM actionview (>= 5.0.0) activesupport (>= 5.0.0) json (2.6.3) + kaminari (1.2.2) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) + actionview + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) + activerecord + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -129,7 +141,7 @@ GEM ast (~> 2.4.1) racc pg (1.5.4) - pry (0.14.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.3) @@ -271,6 +283,7 @@ DEPENDENCIES byebug capybara (>= 3.26) jbuilder (~> 2.7) + kaminari listen (~> 3.3) pg (~> 1.1) pry diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f1eb08d8..f5f0af4c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -2,7 +2,7 @@ class ProjectsController < ApplicationController before_action :set_project, only: %i[show edit update destroy] def index - @projects = Project.order(:id) + @projects = Project.order(params[:sort]).page(params[:page]).per(3) end def show; end diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 57b40db5..bd97171f 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -2,6 +2,10 @@
<%= project.id %>. <%= link_to project.name, project_path(project) %>
@@ -10,3 +14,5 @@<%= button_to "Destroy", project, method: :delete %>