diff --git a/Gemfile b/Gemfile index 76f9a44..3977bf5 100644 --- a/Gemfile +++ b/Gemfile @@ -8,13 +8,15 @@ gem 'bootstrap', '~> 4.1.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.1' # Use sqlite3 as the database for Active Record -gem 'sqlite3' +gem 'pg' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' +gem 'will_paginate' +gem 'will_paginate-bootstrap' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby diff --git a/Gemfile.lock b/Gemfile.lock index d59203c..aa69225 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -117,6 +117,7 @@ GEM nio4r (2.3.1) nokogiri (1.8.5) mini_portile2 (~> 2.3.0) + pg (1.1.3) popper_js (1.14.3) public_suffix (3.0.3) puma (3.12.0) @@ -180,7 +181,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) thor (0.20.0) thread_safe (0.3.6) tilt (2.0.8) @@ -199,6 +199,9 @@ GEM websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) + will_paginate (3.1.6) + will_paginate-bootstrap (1.0.1) + will_paginate (>= 3.0.3) xpath (3.2.0) nokogiri (~> 1.8) @@ -216,20 +219,22 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (>= 3.0.5, < 3.2) + pg puma (~> 3.11) rails (~> 5.2.1) sass-rails (~> 5.0) selenium-webdriver spring spring-watcher-listen (~> 2.0.0) - sqlite3 turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) + will_paginate + will_paginate-bootstrap RUBY VERSION ruby 2.5.1p57 BUNDLED WITH - 1.16.6 + 1.17.1 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 82e6f0f..7548ef3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,7 +10,13 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // +//= require jquery3 +//= require popper +//= require bootstrap //= require rails-ujs //= require activestorage //= require turbolinks //= require_tree . +$('#myModal').on('shown.bs.modal', function () { + $('#myInput').trigger('focus') +}) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index f1784e0..ef36dc1 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -13,4 +13,4 @@ *= require_tree . *= require_self */ -@import "bootstrap"; \ No newline at end of file +@import "bootstrap"; diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 443a9cd..6420346 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -12,6 +12,12 @@ def create end end + def destroy + User.find(session[:user_id]) + session[:user_id] = nil + redirect_to :root + end + private def user_params params.require(:user).permit(:name, :password) diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index bf173b5..dea8907 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -3,7 +3,7 @@ class TasksController < ApplicationController def index @task = Task.new - @tasks = current_user.tasks.q(params[:q]) + @tasks = current_user.tasks.q(params[:q]).paginate(:page => params[:page], :per_page => 10) end def create diff --git a/app/views/tasks/_form.html.erb b/app/views/tasks/_form.html.erb index 350ab27..b4ed89c 100644 --- a/app/views/tasks/_form.html.erb +++ b/app/views/tasks/_form.html.erb @@ -1,25 +1,33 @@ -<%= form_for @task, remote: true do |f| %> -