├── .gitignore ├── .rspec ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── cable.js │ │ ├── channels │ │ │ └── .keep │ │ ├── comments.coffee │ │ ├── home.coffee │ │ ├── sessions.coffee │ │ └── users.coffee │ └── stylesheets │ │ ├── application.scss │ │ ├── base.scss │ │ ├── boards.scss │ │ ├── comments.scss │ │ ├── home.scss │ │ ├── sessions.scss │ │ └── users.scss ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── boards_controller.rb │ ├── comments_controller.rb │ ├── concerns │ │ └── .keep │ ├── home_controller.rb │ ├── sessions_controller.rb │ └── users_controller.rb ├── helpers │ ├── application_helper.rb │ ├── comments_helper.rb │ ├── home_helper.rb │ ├── sessions_helper.rb │ └── users_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ ├── board.rb │ ├── board_tag_relation.rb │ ├── comment.rb │ ├── concerns │ │ └── .keep │ ├── tag.rb │ └── user.rb └── views │ ├── application │ └── _header.html.erb │ ├── boards │ ├── _board.html.erb │ ├── _form.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ ├── new.html.erb │ └── show.html.erb │ ├── comments │ ├── _comment.html.erb │ └── _form.html.erb │ ├── home │ └── index.html.erb │ ├── kaminari │ ├── _first_page.html.erb │ ├── _gap.html.erb │ ├── _last_page.html.erb │ ├── _next_page.html.erb │ ├── _page.html.erb │ ├── _paginator.html.erb │ └── _prev_page.html.erb │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ ├── shared │ └── _error_messages.html.erb │ └── users │ ├── _form.html.erb │ ├── _login_form.html.erb │ ├── me.html.erb │ └── new.html.erb ├── bin ├── bundle ├── rails ├── rake ├── setup ├── spring └── update ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── kaminari_config.rb │ ├── mime_types.rb │ ├── new_framework_defaults.rb │ ├── session_store.rb │ ├── time_formats.rb │ └── wrap_parameters.rb ├── locales │ ├── en.yml │ └── ja.yml ├── puma.rb ├── routes.rb ├── secrets.yml └── spring.rb ├── db ├── migrate │ ├── 20180217122153_create_boards.rb │ ├── 20180315233935_create_comments.rb │ ├── 20180324120737_create_tags.rb │ ├── 20180324120941_create_board_tag_relations.rb │ ├── 20180506115954_create_users.rb │ └── 20181128051946_add_birthday_to_user.rb ├── schema.rb └── seeds.rb ├── docker-compose.yml ├── lib ├── assets │ └── .keep └── tasks │ ├── .keep │ └── auto_annotate_models.rake ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── spec ├── controllers │ └── users_controller_spec.rb ├── models │ └── user_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── test ├── controllers │ ├── .keep │ ├── comments_controller_test.rb │ ├── home_controller_test.rb │ ├── sessions_controller_test.rb │ └── users_controller_test.rb ├── fixtures │ ├── .keep │ ├── board_tag_relations.yml │ ├── boards.yml │ ├── comments.yml │ ├── files │ │ └── .keep │ ├── tags.yml │ └── users.yml ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── board_tag_relation_test.rb │ ├── board_test.rb │ ├── comment_test.rb │ ├── tag_test.rb │ └── user_test.rb └── test_helper.rb ├── tmp └── .keep └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore Byebug command history file. 17 | .byebug_history 18 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.4.6 2 | RUN apt-get update -qq && apt-get install -y build-essential nodejs 3 | RUN mkdir /app 4 | WORKDIR /app 5 | COPY Gemfile /app/Gemfile 6 | COPY Gemfile.lock /app/Gemfile.lock 7 | RUN bundle install 8 | COPY . /app 9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '5.2.2' 6 | # Use mysql as the database for Active Record 7 | gem 'mysql2', '>= 0.3.18', '< 0.5' 8 | # Use Puma as the app server 9 | gem 'puma', '~> 3.0' 10 | # Use SCSS for stylesheets 11 | gem 'sass-rails', '~> 5.0' 12 | # Use Uglifier as compressor for JavaScript assets 13 | gem 'uglifier', '>= 1.3.0' 14 | # Use CoffeeScript for .coffee assets and views 15 | gem 'coffee-rails', '~> 4.2' 16 | # See https://github.com/rails/execjs#readme for more supported runtimes 17 | # gem 'therubyracer', platforms: :ruby 18 | gem 'mini_racer', '0.1.14' 19 | 20 | # Use jquery as the JavaScript library 21 | gem 'jquery-rails' 22 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 23 | gem 'turbolinks', '~> 5' 24 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 25 | gem 'jbuilder', '~> 2.5' 26 | # Use Redis adapter to run Action Cable in production 27 | # gem 'redis', '~> 3.0' 28 | # Use ActiveModel has_secure_password 29 | gem 'bcrypt', '~> 3.1.7' 30 | 31 | # Use Capistrano for deployment 32 | # gem 'capistrano-rails', group: :development 33 | 34 | gem 'bootstrap', '~> 4.0.0' 35 | gem 'kaminari' 36 | gem 'rails-i18n' 37 | 38 | group :development, :test do 39 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 | gem 'byebug', platform: :mri 41 | gem 'rails-flog', require: 'flog' 42 | gem 'rspec-rails', '~> 3.8' 43 | gem 'rails-controller-testing' 44 | end 45 | 46 | group :development do 47 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 48 | gem 'web-console' 49 | gem 'listen', '~> 3.0.5' 50 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 51 | gem 'spring' 52 | gem 'spring-watcher-listen', '~> 2.0.0' 53 | gem 'pry-byebug' 54 | gem 'annotate' 55 | end 56 | 57 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 58 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 59 | 60 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.2) 5 | actionpack (= 5.2.2) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.2) 9 | actionpack (= 5.2.2) 10 | actionview (= 5.2.2) 11 | activejob (= 5.2.2) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.2) 15 | actionview (= 5.2.2) 16 | activesupport (= 5.2.2) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.2) 22 | activesupport (= 5.2.2) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.2) 28 | activesupport (= 5.2.2) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.2) 31 | activesupport (= 5.2.2) 32 | activerecord (5.2.2) 33 | activemodel (= 5.2.2) 34 | activesupport (= 5.2.2) 35 | arel (>= 9.0) 36 | activestorage (5.2.2) 37 | actionpack (= 5.2.2) 38 | activerecord (= 5.2.2) 39 | marcel (~> 0.3.1) 40 | activesupport (5.2.2) 41 | concurrent-ruby (~> 1.0, >= 1.0.2) 42 | i18n (>= 0.7, < 2) 43 | minitest (~> 5.1) 44 | tzinfo (~> 1.1) 45 | anbt-sql-formatter (0.0.5) 46 | annotate (2.7.2) 47 | activerecord (>= 3.2, < 6.0) 48 | rake (>= 10.4, < 13.0) 49 | arel (9.0.0) 50 | autoprefixer-rails (8.2.0) 51 | execjs 52 | awesome_print (1.8.0) 53 | bcrypt (3.1.11) 54 | bindex (0.5.0) 55 | bootstrap (4.0.0) 56 | autoprefixer-rails (>= 6.0.3) 57 | popper_js (>= 1.12.9, < 2) 58 | sass (>= 3.5.2) 59 | builder (3.2.3) 60 | byebug (10.0.1) 61 | coderay (1.1.2) 62 | coffee-rails (4.2.2) 63 | coffee-script (>= 2.2.0) 64 | railties (>= 4.0.0) 65 | coffee-script (2.4.1) 66 | coffee-script-source 67 | execjs 68 | coffee-script-source (1.12.2) 69 | concurrent-ruby (1.1.4) 70 | crass (1.0.4) 71 | diff-lcs (1.3) 72 | erubi (1.8.0) 73 | execjs (2.7.0) 74 | ffi (1.9.23) 75 | globalid (0.4.1) 76 | activesupport (>= 4.2.0) 77 | i18n (1.5.1) 78 | concurrent-ruby (~> 1.0) 79 | jbuilder (2.7.0) 80 | activesupport (>= 4.2.0) 81 | multi_json (>= 1.2) 82 | jquery-rails (4.3.1) 83 | rails-dom-testing (>= 1, < 3) 84 | railties (>= 4.2.0) 85 | thor (>= 0.14, < 2.0) 86 | kaminari (1.1.1) 87 | activesupport (>= 4.1.0) 88 | kaminari-actionview (= 1.1.1) 89 | kaminari-activerecord (= 1.1.1) 90 | kaminari-core (= 1.1.1) 91 | kaminari-actionview (1.1.1) 92 | actionview 93 | kaminari-core (= 1.1.1) 94 | kaminari-activerecord (1.1.1) 95 | activerecord 96 | kaminari-core (= 1.1.1) 97 | kaminari-core (1.1.1) 98 | libv8 (5.9.211.38.1) 99 | listen (3.0.8) 100 | rb-fsevent (~> 0.9, >= 0.9.4) 101 | rb-inotify (~> 0.9, >= 0.9.7) 102 | loofah (2.2.3) 103 | crass (~> 1.0.2) 104 | nokogiri (>= 1.5.9) 105 | mail (2.7.1) 106 | mini_mime (>= 0.1.1) 107 | marcel (0.3.3) 108 | mimemagic (~> 0.3.2) 109 | method_source (0.9.2) 110 | mimemagic (0.3.10) 111 | nokogiri (~> 1) 112 | rake 113 | mini_mime (1.0.1) 114 | mini_portile2 (2.4.0) 115 | mini_racer (0.1.14) 116 | libv8 (~> 5.9) 117 | minitest (5.11.3) 118 | multi_json (1.13.1) 119 | mysql2 (0.4.10) 120 | nio4r (2.3.1) 121 | nokogiri (1.10.0) 122 | mini_portile2 (~> 2.4.0) 123 | popper_js (1.12.9) 124 | pry (0.11.3) 125 | coderay (~> 1.1.0) 126 | method_source (~> 0.9.0) 127 | pry-byebug (3.6.0) 128 | byebug (~> 10.0) 129 | pry (~> 0.10) 130 | puma (3.11.3) 131 | rack (2.0.6) 132 | rack-test (1.1.0) 133 | rack (>= 1.0, < 3) 134 | rails (5.2.2) 135 | actioncable (= 5.2.2) 136 | actionmailer (= 5.2.2) 137 | actionpack (= 5.2.2) 138 | actionview (= 5.2.2) 139 | activejob (= 5.2.2) 140 | activemodel (= 5.2.2) 141 | activerecord (= 5.2.2) 142 | activestorage (= 5.2.2) 143 | activesupport (= 5.2.2) 144 | bundler (>= 1.3.0) 145 | railties (= 5.2.2) 146 | sprockets-rails (>= 2.0.0) 147 | rails-controller-testing (1.0.2) 148 | actionpack (~> 5.x, >= 5.0.1) 149 | actionview (~> 5.x, >= 5.0.1) 150 | activesupport (~> 5.x) 151 | rails-dom-testing (2.0.3) 152 | activesupport (>= 4.2.0) 153 | nokogiri (>= 1.6) 154 | rails-flog (1.4.0) 155 | anbt-sql-formatter 156 | awesome_print 157 | rails (>= 3.2.0) 158 | rails-html-sanitizer (1.0.4) 159 | loofah (~> 2.2, >= 2.2.2) 160 | rails-i18n (5.1.1) 161 | i18n (>= 0.7, < 2) 162 | railties (>= 5.0, < 6) 163 | railties (5.2.2) 164 | actionpack (= 5.2.2) 165 | activesupport (= 5.2.2) 166 | method_source 167 | rake (>= 0.8.7) 168 | thor (>= 0.19.0, < 2.0) 169 | rake (12.3.2) 170 | rb-fsevent (0.10.3) 171 | rb-inotify (0.9.10) 172 | ffi (>= 0.5.0, < 2) 173 | rspec-core (3.8.0) 174 | rspec-support (~> 3.8.0) 175 | rspec-expectations (3.8.2) 176 | diff-lcs (>= 1.2.0, < 2.0) 177 | rspec-support (~> 3.8.0) 178 | rspec-mocks (3.8.0) 179 | diff-lcs (>= 1.2.0, < 2.0) 180 | rspec-support (~> 3.8.0) 181 | rspec-rails (3.8.1) 182 | actionpack (>= 3.0) 183 | activesupport (>= 3.0) 184 | railties (>= 3.0) 185 | rspec-core (~> 3.8.0) 186 | rspec-expectations (~> 3.8.0) 187 | rspec-mocks (~> 3.8.0) 188 | rspec-support (~> 3.8.0) 189 | rspec-support (3.8.0) 190 | sass (3.5.6) 191 | sass-listen (~> 4.0.0) 192 | sass-listen (4.0.0) 193 | rb-fsevent (~> 0.9, >= 0.9.4) 194 | rb-inotify (~> 0.9, >= 0.9.7) 195 | sass-rails (5.0.7) 196 | railties (>= 4.0.0, < 6) 197 | sass (~> 3.1) 198 | sprockets (>= 2.8, < 4.0) 199 | sprockets-rails (>= 2.0, < 4.0) 200 | tilt (>= 1.1, < 3) 201 | spring (2.0.2) 202 | activesupport (>= 4.2) 203 | spring-watcher-listen (2.0.1) 204 | listen (>= 2.7, < 4.0) 205 | spring (>= 1.2, < 3.0) 206 | sprockets (3.7.2) 207 | concurrent-ruby (~> 1.0) 208 | rack (> 1, < 3) 209 | sprockets-rails (3.2.1) 210 | actionpack (>= 4.0) 211 | activesupport (>= 4.0) 212 | sprockets (>= 3.0.0) 213 | thor (0.20.3) 214 | thread_safe (0.3.6) 215 | tilt (2.0.8) 216 | turbolinks (5.1.0) 217 | turbolinks-source (~> 5.1) 218 | turbolinks-source (5.1.0) 219 | tzinfo (1.2.5) 220 | thread_safe (~> 0.1) 221 | uglifier (4.1.8) 222 | execjs (>= 0.3.0, < 3) 223 | web-console (3.5.1) 224 | actionview (>= 5.0) 225 | activemodel (>= 5.0) 226 | bindex (>= 0.4.0) 227 | railties (>= 5.0) 228 | websocket-driver (0.7.0) 229 | websocket-extensions (>= 0.1.0) 230 | websocket-extensions (0.1.3) 231 | 232 | PLATFORMS 233 | ruby 234 | 235 | DEPENDENCIES 236 | annotate 237 | bcrypt (~> 3.1.7) 238 | bootstrap (~> 4.0.0) 239 | byebug 240 | coffee-rails (~> 4.2) 241 | jbuilder (~> 2.5) 242 | jquery-rails 243 | kaminari 244 | listen (~> 3.0.5) 245 | mini_racer (= 0.1.14) 246 | mysql2 (>= 0.3.18, < 0.5) 247 | pry-byebug 248 | puma (~> 3.0) 249 | rails (= 5.2.2) 250 | rails-controller-testing 251 | rails-flog 252 | rails-i18n 253 | rspec-rails (~> 3.8) 254 | sass-rails (~> 5.0) 255 | spring 256 | spring-watcher-listen (~> 2.0.0) 257 | turbolinks (~> 5) 258 | tzinfo-data 259 | uglifier (>= 1.3.0) 260 | web-console 261 | 262 | BUNDLED WITH 263 | 1.17.3 264 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery3 14 | //= require popper 15 | //= require bootstrap-sprockets 16 | //= require jquery_ujs 17 | //= require turbolinks 18 | //= require_tree . 19 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the rails generate channel command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/comments.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/home.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/sessions.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/users.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 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 other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | */ 14 | @import "bootstrap"; 15 | @import "base"; 16 | @import "boards"; 17 | @import "comments"; 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/base.scss: -------------------------------------------------------------------------------- 1 | h1 { 2 | margin: 30px 0; 3 | } 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/boards.scss: -------------------------------------------------------------------------------- 1 | .boards__table { 2 | tr:hover { 3 | cursor: pointer; 4 | } 5 | } 6 | 7 | .boards__linkBox { 8 | a { 9 | margin: 0 8px; 10 | } 11 | } 12 | 13 | .boards__searchForm { 14 | display: inline-block; 15 | } 16 | 17 | .boards__select { 18 | display: inline-block; 19 | width: auto; 20 | } 21 | -------------------------------------------------------------------------------- /app/assets/stylesheets/comments.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the comments controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | 5 | .p-comment__formBox { 6 | margin: 30px auto; 7 | border: 5px solid #e8e8e8; 8 | padding: 25px; 9 | border-radius: 14px; 10 | } 11 | 12 | .p-comment__formTitle { 13 | border-bottom: 2px solid #dfdfdf; 14 | padding-bottom: 5px; 15 | } 16 | 17 | .p-comment__listTitle { 18 | border-bottom: 2px solid #dfdfdf; 19 | padding-bottom: 5px; 20 | } 21 | 22 | .p-comment__list { 23 | margin: 38px 0; 24 | padding: 20px; 25 | } 26 | 27 | .p-comment__item { 28 | padding: 18px; 29 | border-bottom: 2px dotted #dfdfdf; 30 | } 31 | 32 | .p-comment__bottomLine { 33 | font-size: 15px; 34 | text-align: right; 35 | 36 | > span { 37 | font-size: 14px; 38 | margin: 0 12px; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /app/assets/stylesheets/home.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the home controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/sessions.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the sessions controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/users.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the users controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | before_action :current_user 4 | 5 | private 6 | 7 | def current_user 8 | return unless session[:user_id] 9 | @current_user = User.find_by(id: session[:user_id]) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/boards_controller.rb: -------------------------------------------------------------------------------- 1 | class BoardsController < ApplicationController 2 | before_action :set_target_board, only: %i[show edit update destroy] 3 | 4 | def index 5 | @boards = params[:tag_id].present? ? Tag.find(params[:tag_id]).boards : Board.all 6 | @boards = @boards.page(params[:page]) 7 | end 8 | 9 | def new 10 | @board = Board.new(flash[:board]) 11 | end 12 | 13 | def create 14 | board = Board.new(board_params) 15 | if board.save 16 | flash[:notice] = "「#{board.title}」の掲示板を作成しました" 17 | redirect_to board 18 | else 19 | redirect_to :back, flash: { 20 | board: board, 21 | error_messages: board.errors.full_messages 22 | } 23 | end 24 | end 25 | 26 | def show 27 | @comment = Comment.new(board_id: @board.id) 28 | end 29 | 30 | def edit 31 | @board.attributes = flash[:board] if flash[:board] 32 | end 33 | 34 | def update 35 | if @board.update(board_params) 36 | redirect_to @board 37 | else 38 | redirect_to :back, flash: { 39 | board: @board, 40 | error_messages: @board.errors.full_messages 41 | } 42 | end 43 | end 44 | 45 | def destroy 46 | @board.destroy 47 | redirect_to boards_path, flash: { notice: "「#{@board.title}」の掲示板が削除されました" } 48 | end 49 | 50 | private 51 | 52 | def board_params 53 | params.require(:board).permit(:name, :title, :body, tag_ids: []) 54 | end 55 | 56 | def set_target_board 57 | @board = Board.find(params[:id]) 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /app/controllers/comments_controller.rb: -------------------------------------------------------------------------------- 1 | class CommentsController < ApplicationController 2 | def create 3 | comment = Comment.new(comment_params) 4 | if comment.save 5 | flash[:notice] = 'コメントを投稿しました' 6 | redirect_to comment.board 7 | else 8 | redirect_to :back, flash: { 9 | comment: comment, 10 | error_messages: comment.errors.full_messages 11 | } 12 | end 13 | end 14 | 15 | def destroy 16 | comment = Comment.find(params[:id]) 17 | comment.delete 18 | redirect_to comment.board, flash: { notice: 'コメントが削除されました' } 19 | end 20 | 21 | private 22 | 23 | def comment_params 24 | params.require(:comment).permit(:board_id, :name, :comment) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/sessions_controller.rb: -------------------------------------------------------------------------------- 1 | class SessionsController < ApplicationController 2 | def create 3 | user = User.find_by(name: params[:session][:name]) 4 | if user && user.authenticate(params[:session][:password]) 5 | session[:user_id] = user.id 6 | redirect_to mypage_path 7 | else 8 | render 'home/index' 9 | end 10 | end 11 | 12 | def destroy 13 | session.delete(:user_id) 14 | redirect_to root_path 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | def new 3 | @user = User.new(flash[:user]) 4 | end 5 | 6 | def create 7 | user = User.new(user_params) 8 | if user.save 9 | session[:user_id] = user.id 10 | redirect_to mypage_path 11 | else 12 | flash[:user] = user 13 | flash[:error_messages] = user.errors.full_messages 14 | redirect_back fallback_location: 'http://localhost' 15 | end 16 | end 17 | 18 | def me 19 | end 20 | 21 | private 22 | 23 | def user_params 24 | params.require(:user).permit(:name, :password, :password_confirmation) 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def header_link_item(name, path) 3 | class_name = 'nav-item' 4 | class_name << ' active' if current_page?(path) 5 | 6 | content_tag :li, class: class_name do 7 | link_to name, path, class: 'nav-link' 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/helpers/comments_helper.rb: -------------------------------------------------------------------------------- 1 | module CommentsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/home_helper.rb: -------------------------------------------------------------------------------- 1 | module HomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/sessions_helper.rb: -------------------------------------------------------------------------------- 1 | module SessionsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/board.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: boards 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) 7 | # title :string(255) 8 | # body :text(65535) 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | 13 | class Board < ApplicationRecord 14 | has_many :comments, dependent: :delete_all 15 | has_many :board_tag_relations, dependent: :delete_all 16 | has_many :tags, through: :board_tag_relations 17 | 18 | validates :name, presence: true, length: { maximum: 10 } 19 | validates :title, presence: true, length: { maximum: 30 } 20 | validates :body, presence: true, length: { maximum: 1000 } 21 | end 22 | -------------------------------------------------------------------------------- /app/models/board_tag_relation.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: board_tag_relations 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # tag_id :integer 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | # Indexes 12 | # 13 | # index_board_tag_relations_on_board_id (board_id) 14 | # index_board_tag_relations_on_tag_id (tag_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # fk_rails_... (tag_id => tags.id) 20 | # 21 | 22 | class BoardTagRelation < ApplicationRecord 23 | belongs_to :board 24 | belongs_to :tag 25 | end 26 | -------------------------------------------------------------------------------- /app/models/comment.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: comments 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # name :string(255) not null 8 | # comment :text(65535) not null 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | # Indexes 13 | # 14 | # index_comments_on_board_id (board_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # 20 | 21 | class Comment < ApplicationRecord 22 | belongs_to :board 23 | 24 | validates :name, presence: true, length: { maximum: 10 } 25 | validates :comment, presence: true, length: { maximum: 1000 } 26 | end 27 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/tag.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: tags 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | class Tag < ApplicationRecord 12 | has_many :board_tag_relations, dependent: :delete_all 13 | has_many :boards, through: :board_tag_relations 14 | end 15 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # password_digest :string(255) not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # birthday :date 11 | # 12 | # Indexes 13 | # 14 | # index_users_on_name (name) UNIQUE 15 | # 16 | 17 | class User < ApplicationRecord 18 | has_secure_password 19 | 20 | validates :name, 21 | presence: true, 22 | uniqueness: true, 23 | length: { maximum: 16 }, 24 | format: { 25 | with: /\A[a-z0-9]+\z/, 26 | message: 'は小文字英数字で入力してください' 27 | } 28 | validates :password, 29 | length: { minimum: 8 } 30 | 31 | def age 32 | now = Time.zone.now 33 | (now.strftime('%Y%m%d').to_i - birthday.strftime('%Y%m%d').to_i) / 10000 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /app/views/application/_header.html.erb: -------------------------------------------------------------------------------- 1 | 36 | -------------------------------------------------------------------------------- /app/views/boards/_board.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |

<%= board.title %>

4 | <% board.tags.each do |tag| %> 5 | <%= tag.name %> 6 | <% end %> 7 |
8 |
9 |

<%= simple_format(board.body) %>

10 |

<%= board.name %>

11 |
12 |
13 | -------------------------------------------------------------------------------- /app/views/boards/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= render 'shared/error_messages' %> 2 | 3 | <%= form_with model: board do |f| %> 4 |
5 | <%= f.label :name, '名前' %> 6 | <%= f.text_field :name, class: 'form-control' %> 7 |
8 |
9 | <%= f.label :title, 'タイトル' %> 10 | <%= f.text_field :title, class: 'form-control' %> 11 |
12 |
13 | <%= f.label :body, '本文' %> 14 | <%= f.text_area :body, class: 'form-control', rows: 10 %> 15 |
16 |
17 | タグ 18 | <%= f.collection_check_boxes(:tag_ids, Tag.all, :id, :name) do |tag| %> 19 |
20 | <%= tag.label class: 'form-check-label' do %> 21 | <%= tag.check_box class: 'form-check-input' %> 22 | <%= tag.text %> 23 | <% end %> 24 |
25 | <% end %> 26 |
27 | 28 | <%= f.submit '保存', class: 'btn btn-primary' %> 29 | <% end %> 30 | -------------------------------------------------------------------------------- /app/views/boards/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

掲示板編集

3 | 6 |
7 | <%= render partial: 'form', locals: { board: @board } %> 8 | -------------------------------------------------------------------------------- /app/views/boards/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

掲示板一覧

3 | 16 |
17 | 18 | <% if flash[:notice] %> 19 |
<%= flash[:notice] %>
20 | <% end %> 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | <% @boards.each do |board| %> 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | <% end %> 46 | 47 |
IDタイトル作成者作成日時更新日時
<%= board.id %><%= board.title %><%= board.name %><%= board.created_at.to_s(:datetime_jp) %><%= board.updated_at.to_s(:datetime_jp) %><%= link_to '詳細', board, class: 'btn btn-outline-dark' %><%= link_to '削除', board, class: 'btn btn-outline-dark', method: :delete %>
48 | 49 | <%= paginate @boards %> 50 | -------------------------------------------------------------------------------- /app/views/boards/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

掲示板作成

3 | 6 |
7 | <%= render partial: 'form', locals: { board: @board } %> 8 | -------------------------------------------------------------------------------- /app/views/boards/show.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 6 |
7 | 8 | <% if flash[:notice] %> 9 |
<%= flash[:notice] %>
10 | <% end %> 11 | 12 | <%= render @board %> 13 | 14 |
15 |
コメント
16 | <%= render @board.comments %> 17 |
18 | 19 | <%= render partial: 'comments/form', locals: { comment: @comment } %> 20 | -------------------------------------------------------------------------------- /app/views/comments/_comment.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

<%= simple_format(comment.comment) %>

3 |
4 | <%= comment.name %> 5 | <%= comment.created_at.to_s(:datetime_jp) %> 6 | <%= link_to '削除', comment, method: :delete, data: { confirm: '削除してよろしいですか?' } %> 7 |
8 |
9 | -------------------------------------------------------------------------------- /app/views/comments/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= render 'shared/error_messages' %> 2 | 3 |
4 |

コメント記入

5 | <%= form_with model: comment do |f| %> 6 | <%= f.hidden_field :board_id %> 7 |
8 | <%= f.label :name, '名前' %> 9 | <%= f.text_field :name, class: 'form-control' %> 10 |
11 |
12 | <%= f.label :comment, 'コメント' %> 13 | <%= f.text_area :comment, class: 'form-control', rows: 4 %> 14 |
15 | <%= f.submit '送信', class: 'btn btn-primary' %> 16 | <% end %> 17 |
18 | -------------------------------------------------------------------------------- /app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 | <%= render partial: 'users/login_form' %> 2 | -------------------------------------------------------------------------------- /app/views/kaminari/_first_page.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %> 3 |
  • 4 | -------------------------------------------------------------------------------- /app/views/kaminari/_gap.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %> 3 |
  • 4 | -------------------------------------------------------------------------------- /app/views/kaminari/_last_page.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %> 3 |
  • 4 | -------------------------------------------------------------------------------- /app/views/kaminari/_next_page.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %> 3 |
  • 4 | -------------------------------------------------------------------------------- /app/views/kaminari/_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if page.current? %> 2 |
  • 3 | <%= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %> 4 |
  • 5 | <% else %> 6 |
  • 7 | <%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %> 8 |
  • 9 | <% end %> 10 | -------------------------------------------------------------------------------- /app/views/kaminari/_paginator.html.erb: -------------------------------------------------------------------------------- 1 | <%= paginator.render do %> 2 | 17 | <% end %> 18 | -------------------------------------------------------------------------------- /app/views/kaminari/_prev_page.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %> 3 |
  • 4 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | App 5 | <%= csrf_meta_tags %> 6 | 7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 9 | 10 | 11 | 12 | <%= render 'header' %> 13 |
    14 | <%= yield %> 15 |
    16 | 17 | 18 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/shared/_error_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% if flash[:error_messages] %> 2 |
    3 |
    9 | <% end %> 10 | -------------------------------------------------------------------------------- /app/views/users/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= render 'shared/error_messages' %> 2 | 3 | <%= form_with model: user do |f| %> 4 |
    5 | <%= f.label :name, 'ユーザー名' %> 6 | <%= f.text_field :name, class: 'form-control' %> 7 |
    8 |
    9 | <%= f.label :password, 'パスワード' %> 10 | <%= f.password_field :password, class: 'form-control' %> 11 |
    12 |
    13 | <%= f.label :password_confirmation, 'パスワード(確認)' %> 14 | <%= f.password_field :password_confirmation, class: 'form-control' %> 15 |
    16 | 17 | <%= f.submit '作成', class: 'btn btn-primary' %> 18 | <% end %> 19 | -------------------------------------------------------------------------------- /app/views/users/_login_form.html.erb: -------------------------------------------------------------------------------- 1 |

    ログイン

    2 | 3 | <%= form_with scope: :session, url: login_path do |f| %> 4 |
    5 | <%= f.label :name, 'ユーザー名' %> 6 | <%= f.text_field :name, class: 'form-control' %> 7 |
    8 |
    9 | <%= f.label :password, 'パスワード' %> 10 | <%= f.password_field :password, class: 'form-control' %> 11 |
    12 | <%= f.submit 'ログイン', class: 'btn btn-primary' %> 13 | <% end %> 14 | -------------------------------------------------------------------------------- /app/views/users/me.html.erb: -------------------------------------------------------------------------------- 1 |

    マイページ

    2 | 3 | <%= @current_user.name %> 4 | -------------------------------------------------------------------------------- /app/views/users/new.html.erb: -------------------------------------------------------------------------------- 1 |

    ユーザー登録

    2 | <%= render partial: 'form', locals: { user: @user } %> 3 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # puts "\n== Copying sample files ==" 22 | # unless File.exist?('config/database.yml') 23 | # cp 'config/database.yml.sample', 'config/database.yml' 24 | # end 25 | 26 | puts "\n== Preparing database ==" 27 | system! 'bin/rails db:setup' 28 | 29 | puts "\n== Removing old logs and tempfiles ==" 30 | system! 'bin/rails log:clear tmp:clear' 31 | 32 | puts "\n== Restarting application server ==" 33 | system! 'bin/rails restart' 34 | end 35 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module App 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | config.i18n.default_locale = :ja 15 | config.time_zone = 'Tokyo' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # MySQL. Versions 5.0 and up are supported. 2 | # 3 | # Install the MySQL driver 4 | # gem install mysql2 5 | # 6 | # Ensure the MySQL gem is defined in your Gemfile 7 | # gem 'mysql2' 8 | # 9 | # And be sure to use new-style password hashing: 10 | # http://dev.mysql.com/doc/refman/5.7/en/old-client.html 11 | # 12 | default: &default 13 | adapter: mysql2 14 | encoding: utf8 15 | pool: 5 16 | username: root 17 | password: password 18 | host: db 19 | 20 | development: 21 | <<: *default 22 | database: app_development 23 | 24 | # Warning: The database defined as "test" will be erased and 25 | # re-generated from your development database when you run "rake". 26 | # Do not set this db to the same as development or production. 27 | test: 28 | <<: *default 29 | database: app_test 30 | 31 | # As with config/secrets.yml, you never want to store sensitive information, 32 | # like your database password, in your source code. If your source code is 33 | # ever seen by anyone, they now have access to your database. 34 | # 35 | # Instead, provide the password as a unix environment variable when you boot 36 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 37 | # for a full rundown on how to provide these environment variables in a 38 | # production deployment. 39 | # 40 | # On Heroku and other platform providers, you may have a full connection URL 41 | # available as an environment variable. For example: 42 | # 43 | # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 44 | # 45 | # You can use this database configuration with: 46 | # 47 | # production: 48 | # url: <%= ENV['DATABASE_URL'] %> 49 | # 50 | production: 51 | <<: *default 52 | database: app_production 53 | username: app 54 | password: <%= ENV['APP_DATABASE_PASSWORD'] %> 55 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | config.reload_classes_only_on_change = false 9 | 10 | # Do not eager load code on boot. 11 | config.eager_load = false 12 | 13 | # Show full error reports. 14 | config.consider_all_requests_local = true 15 | 16 | # Enable/disable caching. By default caching is disabled. 17 | if Rails.root.join('tmp/caching-dev.txt').exist? 18 | config.action_controller.perform_caching = true 19 | 20 | config.cache_store = :memory_store 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => 'public, max-age=172800' 23 | } 24 | else 25 | config.action_controller.perform_caching = false 26 | 27 | config.cache_store = :null_store 28 | end 29 | 30 | # Don't care if the mailer can't send. 31 | config.action_mailer.raise_delivery_errors = false 32 | 33 | config.action_mailer.perform_caching = false 34 | 35 | # Print deprecation notices to the Rails logger. 36 | config.active_support.deprecation = :log 37 | 38 | # Raise an error on page load if there are pending migrations. 39 | config.active_record.migration_error = :page_load 40 | 41 | # Debug mode disables concatenation and preprocessing of assets. 42 | # This option may cause significant delays in view rendering with a large 43 | # number of complex assets. 44 | config.assets.debug = true 45 | 46 | # Suppress logger output for asset requests. 47 | config.assets.quiet = true 48 | 49 | # Raises error for missing translations 50 | # config.action_view.raise_on_missing_translations = true 51 | 52 | # Use an evented file watcher to asynchronously detect changes in source code, 53 | # routes, locales, etc. This feature depends on the listen gem. 54 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 55 | end 56 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Disable serving static files from the `/public` folder by default since 18 | # Apache or NGINX already handles this. 19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 20 | 21 | # Compress JavaScripts and CSS. 22 | config.assets.js_compressor = :uglifier 23 | # config.assets.css_compressor = :sass 24 | 25 | # Do not fallback to assets pipeline if a precompiled asset is missed. 26 | config.assets.compile = false 27 | 28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 29 | 30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 31 | # config.action_controller.asset_host = 'http://assets.example.com' 32 | 33 | # Specifies the header that your server uses for sending files. 34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 36 | 37 | # Mount Action Cable outside main process or domain 38 | # config.action_cable.mount_path = nil 39 | # config.action_cable.url = 'wss://example.com/cable' 40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Use the lowest log level to ensure availability of diagnostic information 46 | # when problems arise. 47 | config.log_level = :debug 48 | 49 | # Prepend all log lines with the following tags. 50 | config.log_tags = [ :request_id ] 51 | 52 | # Use a different cache store in production. 53 | # config.cache_store = :mem_cache_store 54 | 55 | # Use a real queuing backend for Active Job (and separate queues per environment) 56 | # config.active_job.queue_adapter = :resque 57 | # config.active_job.queue_name_prefix = "app_#{Rails.env}" 58 | config.action_mailer.perform_caching = false 59 | 60 | # Ignore bad email addresses and do not raise email delivery errors. 61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 62 | # config.action_mailer.raise_delivery_errors = false 63 | 64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 65 | # the I18n.default_locale when a translation cannot be found). 66 | config.i18n.fallbacks = true 67 | 68 | # Send deprecation notices to registered listeners. 69 | config.active_support.deprecation = :notify 70 | 71 | # Use default logging formatter so that PID and timestamp are not suppressed. 72 | config.log_formatter = ::Logger::Formatter.new 73 | 74 | # Use a different logger for distributed setups. 75 | # require 'syslog/logger' 76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 77 | 78 | if ENV["RAILS_LOG_TO_STDOUT"].present? 79 | logger = ActiveSupport::Logger.new(STDOUT) 80 | logger.formatter = config.log_formatter 81 | config.logger = ActiveSupport::TaggedLogging.new(logger) 82 | end 83 | 84 | # Do not dump schema after migrations. 85 | config.active_record.dump_schema_after_migration = false 86 | end 87 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => 'public, max-age=3600' 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/kaminari_config.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | Kaminari.configure do |config| 3 | config.default_per_page = 10 4 | # config.max_per_page = nil 5 | # config.window = 4 6 | # config.outer_window = 0 7 | # config.left = 0 8 | # config.right = 0 9 | # config.page_method_name = :page 10 | # config.param_name = :page 11 | # config.params_on_first_page = false 12 | end 13 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.0 upgrade. 4 | # 5 | # Read the Rails 5.0 release notes for more info on each option. 6 | 7 | # Enable per-form CSRF tokens. Previous versions had false. 8 | Rails.application.config.action_controller.per_form_csrf_tokens = true 9 | 10 | # Enable origin-checking CSRF mitigation. Previous versions had false. 11 | Rails.application.config.action_controller.forgery_protection_origin_check = true 12 | 13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. 14 | # Previous versions had false. 15 | ActiveSupport.to_time_preserves_timezone = true 16 | 17 | # Require `belongs_to` associations by default. Previous versions had false. 18 | Rails.application.config.active_record.belongs_to_required_by_default = true 19 | 20 | # Do not halt callback chains when a callback returns false. Previous versions had true. 21 | # ActiveSupport.halt_callback_chains_on_return_false = false 22 | 23 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false. 24 | Rails.application.config.ssl_options = { hsts: { subdomains: true } } 25 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_app_session' 4 | -------------------------------------------------------------------------------- /config/initializers/time_formats.rb: -------------------------------------------------------------------------------- 1 | Time::DATE_FORMATS[:datetime_jp] = '%Y年%m月%d日 %H時%M分' 2 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | ja: 2 | activerecord: 3 | attributes: 4 | user: 5 | name: ユーザー名 6 | password: パスワード 7 | password_confirmation: パスワード(確認) 8 | board: 9 | name: 名前 10 | title: タイトル 11 | body: 本文 12 | comment: 13 | name: 名前 14 | comment: コメント 15 | views: 16 | pagination: 17 | first: 最初 18 | last: 最後 19 | previous: 前 20 | next: 次 21 | truncate: ... 22 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum, this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # The code in the `on_worker_boot` will be called if you are using 36 | # clustered mode by specifying a number of `workers`. After each worker 37 | # process is booted this block will be run, if you are using `preload_app!` 38 | # option you will want to use this block to reconnect to any threads 39 | # or connections that may have been created at application boot, Ruby 40 | # cannot share connections between processes. 41 | # 42 | # on_worker_boot do 43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 44 | # end 45 | 46 | # Allow puma to be restarted by `rails restart` command. 47 | plugin :tmp_restart 48 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | get 'mypage', to: 'users#me' 3 | post 'login', to: 'sessions#create' 4 | delete 'logout', to: 'sessions#destroy' 5 | 6 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 7 | root 'home#index' 8 | resources :users, only: %i[new create] 9 | resources :boards 10 | resources :comments, only: %i[create destroy] 11 | end 12 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: 63aa879c0cc7b86fb5fe9103d0f9a643f3ca076468e2213bdf66d15484bab740475e8efedc57fd43d1756cf00a0fbfd4a3c8cea57bda044661a4fc923b6cfe7f 15 | 16 | test: 17 | secret_key_base: 6d0e1610ceab665b1957160c967684bde46e8fc8d511b705a80eed016b7fa5354398f3f0a095a10516f70adeac425f6e1a0cfc8a4288fe1a0020815c5ad03c12 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /db/migrate/20180217122153_create_boards.rb: -------------------------------------------------------------------------------- 1 | class CreateBoards < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :boards do |t| 4 | t.string :name 5 | t.string :title 6 | t.text :body 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20180315233935_create_comments.rb: -------------------------------------------------------------------------------- 1 | class CreateComments < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :comments do |t| 4 | t.references :board, foreign_key: true 5 | t.string :name, null: false 6 | t.text :comment, null: false 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20180324120737_create_tags.rb: -------------------------------------------------------------------------------- 1 | class CreateTags < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :tags do |t| 4 | t.string :name, null: false 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20180324120941_create_board_tag_relations.rb: -------------------------------------------------------------------------------- 1 | class CreateBoardTagRelations < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :board_tag_relations do |t| 4 | t.references :board, foreign_key: true 5 | t.references :tag, foreign_key: true 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20180506115954_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :users do |t| 4 | t.string :name, null: false 5 | t.string :password_digest, null: false 6 | 7 | t.timestamps 8 | end 9 | add_index :users, :name, unique: true 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20181128051946_add_birthday_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddBirthdayToUser < ActiveRecord::Migration[5.0] 2 | def change 3 | add_column :users, :birthday, :date 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2018_11_28_051946) do 14 | 15 | create_table "board_tag_relations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 16 | t.integer "board_id" 17 | t.integer "tag_id" 18 | t.datetime "created_at", null: false 19 | t.datetime "updated_at", null: false 20 | t.index ["board_id"], name: "index_board_tag_relations_on_board_id" 21 | t.index ["tag_id"], name: "index_board_tag_relations_on_tag_id" 22 | end 23 | 24 | create_table "boards", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 25 | t.string "name" 26 | t.string "title" 27 | t.text "body" 28 | t.datetime "created_at", null: false 29 | t.datetime "updated_at", null: false 30 | end 31 | 32 | create_table "comments", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 33 | t.integer "board_id" 34 | t.string "name", null: false 35 | t.text "comment", null: false 36 | t.datetime "created_at", null: false 37 | t.datetime "updated_at", null: false 38 | t.index ["board_id"], name: "index_comments_on_board_id" 39 | end 40 | 41 | create_table "tags", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 42 | t.string "name", null: false 43 | t.datetime "created_at", null: false 44 | t.datetime "updated_at", null: false 45 | end 46 | 47 | create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| 48 | t.string "name", null: false 49 | t.string "password_digest", null: false 50 | t.datetime "created_at", null: false 51 | t.datetime "updated_at", null: false 52 | t.date "birthday" 53 | t.index ["name"], name: "index_users_on_name", unique: true 54 | end 55 | 56 | add_foreign_key "board_tag_relations", "boards" 57 | add_foreign_key "board_tag_relations", "tags" 58 | add_foreign_key "comments", "boards" 59 | end 60 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | 9 | if Rails.env == 'development' 10 | (1..50).each do |i| 11 | Board.create(name: "ユーザー#{i}", title: "タイトル#{i}", body: "本文#{i}") 12 | end 13 | 14 | Tag.create([ 15 | { name: 'Ruby' }, 16 | { name: 'Ruby on Rails4' }, 17 | { name: 'Ruby on Rails5' }, 18 | { name: 'Python2' }, 19 | { name: 'Python3' }, 20 | { name: 'Django2' } 21 | ]) 22 | end 23 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | web: 4 | build: . 5 | command: bundle exec rails s -p 3000 -b '0.0.0.0' 6 | volumes: 7 | - .:/app 8 | ports: 9 | - 3000:3000 10 | depends_on: 11 | - db 12 | tty: true 13 | stdin_open: true 14 | db: 15 | image: mysql:5.7 16 | volumes: 17 | - db-volume:/var/lib/mysql 18 | environment: 19 | MYSQL_ROOT_PASSWORD: password 20 | volumes: 21 | db-volume: 22 | 23 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/tasks/auto_annotate_models.rake: -------------------------------------------------------------------------------- 1 | # NOTE: only doing this in development as some production environments (Heroku) 2 | # NOTE: are sensitive to local FS writes, and besides -- it's just not proper 3 | # NOTE: to have a dev-mode tool do its thing in production. 4 | if Rails.env.development? 5 | require 'annotate' 6 | task :set_annotation_options do 7 | # You can override any of these by setting an environment variable of the 8 | # same name. 9 | Annotate.set_defaults( 10 | 'routes' => 'false', 11 | 'position_in_routes' => 'before', 12 | 'position_in_class' => 'before', 13 | 'position_in_test' => 'before', 14 | 'position_in_fixture' => 'before', 15 | 'position_in_factory' => 'before', 16 | 'position_in_serializer' => 'before', 17 | 'show_foreign_keys' => 'true', 18 | 'show_complete_foreign_keys' => 'false', 19 | 'show_indexes' => 'true', 20 | 'simple_indexes' => 'false', 21 | 'model_dir' => 'app/models', 22 | 'root_dir' => '', 23 | 'include_version' => 'false', 24 | 'require' => '', 25 | 'exclude_tests' => 'false', 26 | 'exclude_fixtures' => 'false', 27 | 'exclude_factories' => 'false', 28 | 'exclude_serializers' => 'false', 29 | 'exclude_scaffolds' => 'true', 30 | 'exclude_controllers' => 'true', 31 | 'exclude_helpers' => 'true', 32 | 'exclude_sti_subclasses' => 'false', 33 | 'ignore_model_sub_dir' => 'false', 34 | 'ignore_columns' => nil, 35 | 'ignore_routes' => nil, 36 | 'ignore_unknown_models' => 'false', 37 | 'hide_limit_column_types' => 'integer,boolean', 38 | 'hide_default_column_types' => 'json,jsonb,hstore', 39 | 'skip_on_db_migrate' => 'false', 40 | 'format_bare' => 'true', 41 | 'format_rdoc' => 'false', 42 | 'format_markdown' => 'false', 43 | 'sort' => 'false', 44 | 'force' => 'false', 45 | 'trace' => 'false', 46 | 'wrapper_open' => nil, 47 | 'wrapper_close' => nil, 48 | 'with_comment' => true 49 | ) 50 | end 51 | 52 | Annotate.load_tasks 53 | end 54 | -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/log/.keep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    The page you were looking for doesn't exist.

    62 |

    You may have mistyped the address or the page may have moved.

    63 |
    64 |

    If you are the application owner check the logs for more information.

    65 |
    66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    The change you wanted was rejected.

    62 |

    Maybe you tried to change something you didn't have access to.

    63 |
    64 |

    If you are the application owner check the logs for more information.

    65 |
    66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    We're sorry, but something went wrong.

    62 |
    63 |

    If you are the application owner check the logs for more information.

    64 |
    65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /spec/controllers/users_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe UsersController, type: :controller do 4 | describe 'GET #new' do 5 | before { get :new } 6 | 7 | it 'レスポンスコードが200であること' do 8 | expect(response).to have_http_status(:ok) 9 | end 10 | 11 | it 'newテンプレートをレンダリングすること' do 12 | expect(response).to render_template :new 13 | end 14 | 15 | it '新しいuserオブジェクトがビューに渡されること' do 16 | expect(assigns(:user)).to be_a_new User 17 | end 18 | end 19 | 20 | describe 'POST #create' do 21 | before do 22 | @referer = 'http://localhost' 23 | @request.env['HTTP_REFERER'] = @referer 24 | end 25 | 26 | context '正しいユーザー情報が渡って来た場合' do 27 | let(:params) do 28 | { user: { 29 | name: 'user', 30 | password: 'password', 31 | password_confirmation: 'password', 32 | } 33 | } 34 | end 35 | 36 | it 'ユーザーが一人増えていること' do 37 | expect { post :create, params: params }.to change(User, :count).by(1) 38 | end 39 | 40 | it 'マイページにリダイレクトされること' do 41 | expect(post :create, params: params).to redirect_to(mypage_path) 42 | end 43 | end 44 | 45 | context 'パラメータに正しいユーザー名、確認パスワードが含まれていない場合' do 46 | before do 47 | post(:create, params: { 48 | user: { 49 | name: 'ユーザー1', 50 | password: 'password', 51 | password_confirmation: 'invalid_password' 52 | } 53 | }) 54 | end 55 | 56 | it 'リファラーにリダイレクトされること' do 57 | expect(response).to redirect_to(@referer) 58 | end 59 | 60 | it 'ユーザー名のエラーメッセージが含まれていること' do 61 | expect(flash[:error_messages]).to include 'ユーザー名は小文字英数字で入力してください' 62 | end 63 | 64 | it 'パスワード確認のエラーメッセージが含まれていること' do 65 | expect(flash[:error_messages]).to include 'パスワード(確認)とパスワードの入力が一致しません' 66 | end 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # password_digest :string(255) not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # birthday :date 11 | # 12 | # Indexes 13 | # 14 | # index_users_on_name (name) UNIQUE 15 | # 16 | 17 | require 'rails_helper' 18 | 19 | RSpec.describe User, type: :model do 20 | describe '#age' do 21 | before do 22 | allow(Time.zone).to receive(:now).and_return(Time.zone.parse('2018/04/01')) 23 | end 24 | 25 | context '20年前の生年月日の場合' do 26 | let(:user) { User.new(birthday: Time.zone.now - 20.years) } 27 | 28 | it '年齢が20歳であること' do 29 | expect(user.age).to eq 20 30 | end 31 | end 32 | 33 | context '10年前に生まれた場合でちょうど誕生日の場合' do 34 | let(:user) { User.new(birthday: Time.zone.parse('2008/04/01')) } 35 | 36 | it '年齢が10歳であること' do 37 | expect(user.age).to eq 10 38 | end 39 | end 40 | 41 | context '10年前に生まれた場合で誕生日が来ていない場合' do 42 | let(:user) { User.new(birthday: Time.zone.parse('2008/04/02')) } 43 | 44 | it '年齢が9歳であること' do 45 | expect(user.age).to eq 9 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | ENV['RAILS_ENV'] ||= 'test' 4 | require File.expand_path('../../config/environment', __FILE__) 5 | # Prevent database truncation if the environment is production 6 | abort("The Rails environment is running in production mode!") if Rails.env.production? 7 | require 'rspec/rails' 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } 24 | 25 | # Checks for pending migrations and applies them before tests are run. 26 | # If you are not using ActiveRecord, you can remove these lines. 27 | begin 28 | ActiveRecord::Migration.maintain_test_schema! 29 | rescue ActiveRecord::PendingMigrationError => e 30 | puts e.to_s.strip 31 | exit 1 32 | end 33 | RSpec.configure do |config| 34 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 35 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 36 | 37 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 38 | # examples within a transaction, remove the following line or assign false 39 | # instead of true. 40 | config.use_transactional_fixtures = true 41 | 42 | # RSpec Rails can automatically mix in different behaviours to your tests 43 | # based on their file location, for example enabling you to call `get` and 44 | # `post` in specs under `spec/controllers`. 45 | # 46 | # You can disable this behaviour by removing the line below, and instead 47 | # explicitly tag your specs with their type, e.g.: 48 | # 49 | # RSpec.describe UsersController, :type => :controller do 50 | # # ... 51 | # end 52 | # 53 | # The different available types are documented in the features, such as in 54 | # https://relishapp.com/rspec/rspec-rails/docs 55 | config.infer_spec_type_from_file_location! 56 | 57 | # Filter lines from Rails gems in backtraces. 58 | config.filter_rails_from_backtrace! 59 | # arbitrary gems may also be filtered via: 60 | # config.filter_gems_from_backtrace("gem name") 61 | end 62 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | =begin 50 | # This allows you to limit a spec run to individual examples or groups 51 | # you care about by tagging them with `:focus` metadata. When nothing 52 | # is tagged with `:focus`, all examples get run. RSpec also provides 53 | # aliases for `it`, `describe`, and `context` that include `:focus` 54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 55 | config.filter_run_when_matching :focus 56 | 57 | # Allows RSpec to persist some state between runs in order to support 58 | # the `--only-failures` and `--next-failure` CLI options. We recommend 59 | # you configure your source control system to ignore this file. 60 | config.example_status_persistence_file_path = "spec/examples.txt" 61 | 62 | # Limits the available syntax to the non-monkey patched syntax that is 63 | # recommended. For more details, see: 64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 67 | config.disable_monkey_patching! 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = "doc" 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | =end 96 | end 97 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/controllers/.keep -------------------------------------------------------------------------------- /test/controllers/comments_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class CommentsControllerTest < ActionDispatch::IntegrationTest 4 | test "should get create" do 5 | get comments_create_url 6 | assert_response :success 7 | end 8 | 9 | test "should get destroy" do 10 | get comments_destroy_url 11 | assert_response :success 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /test/controllers/home_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class HomeControllerTest < ActionDispatch::IntegrationTest 4 | test "should get index" do 5 | get home_index_url 6 | assert_response :success 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/controllers/sessions_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class SessionsControllerTest < ActionDispatch::IntegrationTest 4 | test "should get create" do 5 | get sessions_create_url 6 | assert_response :success 7 | end 8 | 9 | test "should get destroy" do 10 | get sessions_destroy_url 11 | assert_response :success 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /test/controllers/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UsersControllerTest < ActionDispatch::IntegrationTest 4 | test "should get new" do 5 | get users_new_url 6 | assert_response :success 7 | end 8 | 9 | test "should get create" do 10 | get users_create_url 11 | assert_response :success 12 | end 13 | 14 | test "should get me" do 15 | get users_me_url 16 | assert_response :success 17 | end 18 | 19 | end 20 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/fixtures/.keep -------------------------------------------------------------------------------- /test/fixtures/board_tag_relations.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: board_tag_relations 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # tag_id :integer 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | # Indexes 12 | # 13 | # index_board_tag_relations_on_board_id (board_id) 14 | # index_board_tag_relations_on_tag_id (tag_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # fk_rails_... (tag_id => tags.id) 20 | # 21 | 22 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 23 | 24 | one: 25 | board: one 26 | tag: one 27 | 28 | two: 29 | board: two 30 | tag: two 31 | -------------------------------------------------------------------------------- /test/fixtures/boards.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: boards 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) 7 | # title :string(255) 8 | # body :text(65535) 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | 13 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 14 | 15 | one: 16 | name: MyString 17 | title: MyString 18 | body: MyText 19 | 20 | two: 21 | name: MyString 22 | title: MyString 23 | body: MyText 24 | -------------------------------------------------------------------------------- /test/fixtures/comments.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: comments 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # name :string(255) not null 8 | # comment :text(65535) not null 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | # Indexes 13 | # 14 | # index_comments_on_board_id (board_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # 20 | 21 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 22 | 23 | one: 24 | board: one 25 | name: MyString 26 | comment: MyText 27 | 28 | two: 29 | board: two 30 | name: MyString 31 | comment: MyText 32 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/fixtures/files/.keep -------------------------------------------------------------------------------- /test/fixtures/tags.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: tags 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 12 | 13 | one: 14 | name: MyString 15 | 16 | two: 17 | name: MyString 18 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # password_digest :string(255) not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # birthday :date 11 | # 12 | # Indexes 13 | # 14 | # index_users_on_name (name) UNIQUE 15 | # 16 | 17 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 18 | 19 | one: 20 | name: MyString 21 | password_digest: MyString 22 | 23 | two: 24 | name: MyString 25 | password_digest: MyString 26 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/helpers/.keep -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/integration/.keep -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/mailers/.keep -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/test/models/.keep -------------------------------------------------------------------------------- /test/models/board_tag_relation_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: board_tag_relations 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # tag_id :integer 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # 11 | # Indexes 12 | # 13 | # index_board_tag_relations_on_board_id (board_id) 14 | # index_board_tag_relations_on_tag_id (tag_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # fk_rails_... (tag_id => tags.id) 20 | # 21 | 22 | require 'test_helper' 23 | 24 | class BoardTagRelationTest < ActiveSupport::TestCase 25 | # test "the truth" do 26 | # assert true 27 | # end 28 | end 29 | -------------------------------------------------------------------------------- /test/models/board_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: boards 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) 7 | # title :string(255) 8 | # body :text(65535) 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | 13 | require 'test_helper' 14 | 15 | class BoardTest < ActiveSupport::TestCase 16 | # test "the truth" do 17 | # assert true 18 | # end 19 | end 20 | -------------------------------------------------------------------------------- /test/models/comment_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: comments 4 | # 5 | # id :integer not null, primary key 6 | # board_id :integer 7 | # name :string(255) not null 8 | # comment :text(65535) not null 9 | # created_at :datetime not null 10 | # updated_at :datetime not null 11 | # 12 | # Indexes 13 | # 14 | # index_comments_on_board_id (board_id) 15 | # 16 | # Foreign Keys 17 | # 18 | # fk_rails_... (board_id => boards.id) 19 | # 20 | 21 | require 'test_helper' 22 | 23 | class CommentTest < ActiveSupport::TestCase 24 | # test "the truth" do 25 | # assert true 26 | # end 27 | end 28 | -------------------------------------------------------------------------------- /test/models/tag_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: tags 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # created_at :datetime not null 8 | # updated_at :datetime not null 9 | # 10 | 11 | require 'test_helper' 12 | 13 | class TagTest < ActiveSupport::TestCase 14 | # test "the truth" do 15 | # assert true 16 | # end 17 | end 18 | -------------------------------------------------------------------------------- /test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: users 4 | # 5 | # id :integer not null, primary key 6 | # name :string(255) not null 7 | # password_digest :string(255) not null 8 | # created_at :datetime not null 9 | # updated_at :datetime not null 10 | # birthday :date 11 | # 12 | # Indexes 13 | # 14 | # index_users_on_name (name) UNIQUE 15 | # 16 | 17 | require 'test_helper' 18 | 19 | class UserTest < ActiveSupport::TestCase 20 | # test "the truth" do 21 | # assert true 22 | # end 23 | end 24 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/tmp/.keep -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoji/rails-lecture/0c4fd7a2cf4260dd7d18d8e3a31f5c50790e1cc4/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------