From 48400e564688fe4b11b6d0ea5e9d78c8990a05d7 Mon Sep 17 00:00:00 2001
From: ceahmad
Date: Sun, 3 Mar 2019 14:51:09 +0300
Subject: [PATCH 1/3] add library of movies and books
---
.bundle/config | 2 +
library/.gitignore | 31 +++
library/.ruby-version | 1 +
library/Gemfile | 62 +++++
library/Gemfile.lock | 220 ++++++++++++++++++
library/README.md | 24 ++
library/Rakefile | 6 +
library/app/assets/config/manifest.js | 3 +
library/app/assets/images/.keep | 0
library/app/assets/javascripts/application.js | 16 ++
library/app/assets/javascripts/cable.js | 13 ++
library/app/assets/javascripts/channels/.keep | 0
.../app/assets/stylesheets/application.css | 15 ++
.../app/channels/application_cable/channel.rb | 4 +
.../channels/application_cable/connection.rb | 4 +
.../app/controllers/application_controller.rb | 2 +
library/app/controllers/books_controller.rb | 55 +++++
library/app/controllers/concerns/.keep | 0
.../app/controllers/ingredients_controller.rb | 15 ++
library/app/controllers/movies_controller.rb | 54 +++++
library/app/helpers/application_helper.rb | 2 +
library/app/jobs/application_job.rb | 2 +
library/app/mailers/application_mailer.rb | 4 +
library/app/models/application_record.rb | 3 +
library/app/models/book.rb | 5 +
library/app/models/concerns/.keep | 0
library/app/models/ingredient.rb | 5 +
library/app/models/movie.rb | 5 +
library/app/views/books/edit.html.erb | 20 ++
library/app/views/books/index.html.erb | 20 ++
library/app/views/books/new.html.erb | 20 ++
library/app/views/books/show.html.erb | 13 ++
library/app/views/ingredients/index.html.erb | 11 +
library/app/views/ingredients/show.html.erb | 12 +
.../app/views/layouts/application.html.erb | 15 ++
library/app/views/layouts/mailer.html.erb | 13 ++
library/app/views/layouts/mailer.text.erb | 1 +
library/app/views/movies/edit.html.erb | 25 ++
library/app/views/movies/index.html.erb | 18 ++
library/app/views/movies/new.html.erb | 25 ++
library/app/views/movies/show.html.erb | 10 +
library/bin/bundle | 3 +
library/bin/rails | 4 +
library/bin/rake | 4 +
library/bin/setup | 36 +++
library/bin/update | 31 +++
library/bin/yarn | 11 +
library/config.ru | 5 +
library/config/application.rb | 19 ++
library/config/boot.rb | 4 +
library/config/cable.yml | 10 +
library/config/credentials.yml.enc | 1 +
library/config/database.yml | 25 ++
library/config/environment.rb | 5 +
library/config/environments/development.rb | 61 +++++
library/config/environments/production.rb | 94 ++++++++
library/config/environments/test.rb | 46 ++++
.../application_controller_renderer.rb | 8 +
library/config/initializers/assets.rb | 14 ++
.../initializers/backtrace_silencers.rb | 7 +
.../initializers/content_security_policy.rb | 25 ++
.../config/initializers/cookies_serializer.rb | 5 +
.../initializers/filter_parameter_logging.rb | 4 +
library/config/initializers/inflections.rb | 16 ++
library/config/initializers/mime_types.rb | 4 +
.../config/initializers/wrap_parameters.rb | 14 ++
library/config/locales/en.yml | 33 +++
library/config/puma.rb | 34 +++
library/config/routes.rb | 23 ++
library/config/spring.rb | 6 +
library/config/storage.yml | 34 +++
library/db/migrate/000_create_books.rb | 11 +
library/db/migrate/001_create_movies.rb | 10 +
library/db/migrate/002_create_ingredients.rb | 13 ++
library/db/schema.rb | 40 ++++
library/db/seeds.rb | 7 +
library/lib/assets/.keep | 0
library/lib/tasks/.keep | 0
library/log/.keep | 0
library/package.json | 5 +
library/public/404.html | 67 ++++++
library/public/422.html | 67 ++++++
library/public/500.html | 66 ++++++
.../public/apple-touch-icon-precomposed.png | 0
library/public/apple-touch-icon.png | 0
library/public/favicon.ico | 0
library/public/robots.txt | 1 +
library/storage/.keep | 0
library/test/application_system_test_case.rb | 5 +
library/test/controllers/.keep | 0
library/test/fixtures/.keep | 0
library/test/fixtures/files/.keep | 0
library/test/helpers/.keep | 0
library/test/integration/.keep | 0
library/test/mailers/.keep | 0
library/test/models/.keep | 0
library/test/system/.keep | 0
library/test/test_helper.rb | 10 +
library/tmp/.keep | 0
library/vendor/.keep | 0
100 files changed, 1644 insertions(+)
create mode 100644 .bundle/config
create mode 100644 library/.gitignore
create mode 100644 library/.ruby-version
create mode 100644 library/Gemfile
create mode 100644 library/Gemfile.lock
create mode 100644 library/README.md
create mode 100644 library/Rakefile
create mode 100644 library/app/assets/config/manifest.js
create mode 100644 library/app/assets/images/.keep
create mode 100644 library/app/assets/javascripts/application.js
create mode 100644 library/app/assets/javascripts/cable.js
create mode 100644 library/app/assets/javascripts/channels/.keep
create mode 100644 library/app/assets/stylesheets/application.css
create mode 100644 library/app/channels/application_cable/channel.rb
create mode 100644 library/app/channels/application_cable/connection.rb
create mode 100644 library/app/controllers/application_controller.rb
create mode 100644 library/app/controllers/books_controller.rb
create mode 100644 library/app/controllers/concerns/.keep
create mode 100644 library/app/controllers/ingredients_controller.rb
create mode 100644 library/app/controllers/movies_controller.rb
create mode 100644 library/app/helpers/application_helper.rb
create mode 100644 library/app/jobs/application_job.rb
create mode 100644 library/app/mailers/application_mailer.rb
create mode 100644 library/app/models/application_record.rb
create mode 100644 library/app/models/book.rb
create mode 100644 library/app/models/concerns/.keep
create mode 100644 library/app/models/ingredient.rb
create mode 100644 library/app/models/movie.rb
create mode 100644 library/app/views/books/edit.html.erb
create mode 100644 library/app/views/books/index.html.erb
create mode 100644 library/app/views/books/new.html.erb
create mode 100644 library/app/views/books/show.html.erb
create mode 100644 library/app/views/ingredients/index.html.erb
create mode 100644 library/app/views/ingredients/show.html.erb
create mode 100644 library/app/views/layouts/application.html.erb
create mode 100644 library/app/views/layouts/mailer.html.erb
create mode 100644 library/app/views/layouts/mailer.text.erb
create mode 100644 library/app/views/movies/edit.html.erb
create mode 100644 library/app/views/movies/index.html.erb
create mode 100644 library/app/views/movies/new.html.erb
create mode 100644 library/app/views/movies/show.html.erb
create mode 100755 library/bin/bundle
create mode 100755 library/bin/rails
create mode 100755 library/bin/rake
create mode 100755 library/bin/setup
create mode 100755 library/bin/update
create mode 100755 library/bin/yarn
create mode 100644 library/config.ru
create mode 100644 library/config/application.rb
create mode 100644 library/config/boot.rb
create mode 100644 library/config/cable.yml
create mode 100644 library/config/credentials.yml.enc
create mode 100644 library/config/database.yml
create mode 100644 library/config/environment.rb
create mode 100644 library/config/environments/development.rb
create mode 100644 library/config/environments/production.rb
create mode 100644 library/config/environments/test.rb
create mode 100644 library/config/initializers/application_controller_renderer.rb
create mode 100644 library/config/initializers/assets.rb
create mode 100644 library/config/initializers/backtrace_silencers.rb
create mode 100644 library/config/initializers/content_security_policy.rb
create mode 100644 library/config/initializers/cookies_serializer.rb
create mode 100644 library/config/initializers/filter_parameter_logging.rb
create mode 100644 library/config/initializers/inflections.rb
create mode 100644 library/config/initializers/mime_types.rb
create mode 100644 library/config/initializers/wrap_parameters.rb
create mode 100644 library/config/locales/en.yml
create mode 100644 library/config/puma.rb
create mode 100644 library/config/routes.rb
create mode 100644 library/config/spring.rb
create mode 100644 library/config/storage.yml
create mode 100644 library/db/migrate/000_create_books.rb
create mode 100644 library/db/migrate/001_create_movies.rb
create mode 100644 library/db/migrate/002_create_ingredients.rb
create mode 100644 library/db/schema.rb
create mode 100644 library/db/seeds.rb
create mode 100644 library/lib/assets/.keep
create mode 100644 library/lib/tasks/.keep
create mode 100644 library/log/.keep
create mode 100644 library/package.json
create mode 100644 library/public/404.html
create mode 100644 library/public/422.html
create mode 100644 library/public/500.html
create mode 100644 library/public/apple-touch-icon-precomposed.png
create mode 100644 library/public/apple-touch-icon.png
create mode 100644 library/public/favicon.ico
create mode 100644 library/public/robots.txt
create mode 100644 library/storage/.keep
create mode 100644 library/test/application_system_test_case.rb
create mode 100644 library/test/controllers/.keep
create mode 100644 library/test/fixtures/.keep
create mode 100644 library/test/fixtures/files/.keep
create mode 100644 library/test/helpers/.keep
create mode 100644 library/test/integration/.keep
create mode 100644 library/test/mailers/.keep
create mode 100644 library/test/models/.keep
create mode 100644 library/test/system/.keep
create mode 100644 library/test/test_helper.rb
create mode 100644 library/tmp/.keep
create mode 100644 library/vendor/.keep
diff --git a/.bundle/config b/.bundle/config
new file mode 100644
index 0000000..2369228
--- /dev/null
+++ b/.bundle/config
@@ -0,0 +1,2 @@
+---
+BUNDLE_PATH: "vendor/bundle"
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..81452db
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1,31 @@
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile '~/.gitignore_global'
+
+# Ignore bundler config.
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+/db/*.sqlite3-journal
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
+
+# Ignore uploaded files in development
+/storage/*
+!/storage/.keep
+
+/node_modules
+/yarn-error.log
+
+/public/assets
+.byebug_history
+
+# Ignore master key for decrypting credentials and more.
+/config/master.key
diff --git a/library/.ruby-version b/library/.ruby-version
new file mode 100644
index 0000000..94c7e90
--- /dev/null
+++ b/library/.ruby-version
@@ -0,0 +1 @@
+ruby-2.6.1
\ No newline at end of file
diff --git a/library/Gemfile b/library/Gemfile
new file mode 100644
index 0000000..35855cd
--- /dev/null
+++ b/library/Gemfile
@@ -0,0 +1,62 @@
+source 'https://rubygems.org'
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
+
+ruby '2.6.1'
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+gem 'rails', '~> 5.2.2'
+# Use sqlite3 as the database for Active Record
+gem 'sqlite3', '~> 1.3.6'
+# Use Puma as the app server
+gem 'puma', '~> 3.11'
+# Use SCSS for stylesheets
+gem 'sass-rails', '~> 5.0'
+# Use Uglifier as compressor for JavaScript assets
+gem 'uglifier', '>= 1.3.0'
+# See https://github.com/rails/execjs#readme for more supported runtimes
+# gem 'mini_racer', platforms: :ruby
+
+# Use CoffeeScript for .coffee assets and views
+gem 'coffee-rails', '~> 4.2'
+# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
+gem 'turbolinks', '~> 5'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.5'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 4.0'
+# Use ActiveModel has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use ActiveStorage variant
+# gem 'mini_magick', '~> 4.8'
+
+# Use Capistrano for deployment
+# gem 'capistrano-rails', group: :development
+
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', '>= 1.1.0', require: false
+
+group :development, :test do
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
+end
+
+group :development do
+ # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
+ gem 'web-console', '>= 3.3.0'
+ gem 'listen', '>= 3.0.5', '< 3.2'
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+ gem 'spring'
+ gem 'spring-watcher-listen', '~> 2.0.0'
+end
+
+group :test do
+ # Adds support for Capybara system testing and selenium driver
+ gem 'capybara', '>= 2.15'
+ gem 'selenium-webdriver'
+ # Easy installation and use of chromedriver to run system tests with Chrome
+ gem 'chromedriver-helper'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
diff --git a/library/Gemfile.lock b/library/Gemfile.lock
new file mode 100644
index 0000000..4147e59
--- /dev/null
+++ b/library/Gemfile.lock
@@ -0,0 +1,220 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (5.2.2)
+ actionpack (= 5.2.2)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ actionmailer (5.2.2)
+ actionpack (= 5.2.2)
+ actionview (= 5.2.2)
+ activejob (= 5.2.2)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.2.2)
+ actionview (= 5.2.2)
+ activesupport (= 5.2.2)
+ rack (~> 2.0)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ actionview (5.2.2)
+ activesupport (= 5.2.2)
+ builder (~> 3.1)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.2.2)
+ activesupport (= 5.2.2)
+ globalid (>= 0.3.6)
+ activemodel (5.2.2)
+ activesupport (= 5.2.2)
+ activerecord (5.2.2)
+ activemodel (= 5.2.2)
+ activesupport (= 5.2.2)
+ arel (>= 9.0)
+ activestorage (5.2.2)
+ actionpack (= 5.2.2)
+ activerecord (= 5.2.2)
+ marcel (~> 0.3.1)
+ activesupport (5.2.2)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ addressable (2.6.0)
+ public_suffix (>= 2.0.2, < 4.0)
+ archive-zip (0.11.0)
+ io-like (~> 0.3.0)
+ arel (9.0.0)
+ bindex (0.5.0)
+ bootsnap (1.4.1)
+ msgpack (~> 1.0)
+ builder (3.2.3)
+ byebug (11.0.0)
+ capybara (3.14.0)
+ addressable
+ mini_mime (>= 0.1.3)
+ nokogiri (~> 1.8)
+ rack (>= 1.6.0)
+ rack-test (>= 0.6.3)
+ regexp_parser (~> 1.2)
+ xpath (~> 3.2)
+ childprocess (0.9.0)
+ ffi (~> 1.0, >= 1.0.11)
+ chromedriver-helper (2.1.0)
+ archive-zip (~> 0.10)
+ nokogiri (~> 1.8)
+ coffee-rails (4.2.2)
+ coffee-script (>= 2.2.0)
+ railties (>= 4.0.0)
+ coffee-script (2.4.1)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.12.2)
+ concurrent-ruby (1.1.4)
+ crass (1.0.4)
+ erubi (1.8.0)
+ execjs (2.7.0)
+ ffi (1.10.0)
+ globalid (0.4.2)
+ activesupport (>= 4.2.0)
+ i18n (1.5.3)
+ concurrent-ruby (~> 1.0)
+ io-like (0.3.0)
+ jbuilder (2.8.0)
+ activesupport (>= 4.2.0)
+ multi_json (>= 1.2)
+ listen (3.1.5)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ ruby_dep (~> 1.2)
+ loofah (2.2.3)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.7.1)
+ mini_mime (>= 0.1.1)
+ marcel (0.3.3)
+ mimemagic (~> 0.3.2)
+ method_source (0.9.2)
+ mimemagic (0.3.3)
+ mini_mime (1.0.1)
+ mini_portile2 (2.4.0)
+ minitest (5.11.3)
+ msgpack (1.2.6)
+ multi_json (1.13.1)
+ nio4r (2.3.1)
+ nokogiri (1.10.1)
+ mini_portile2 (~> 2.4.0)
+ public_suffix (3.0.3)
+ puma (3.12.0)
+ rack (2.0.6)
+ rack-test (1.1.0)
+ rack (>= 1.0, < 3)
+ rails (5.2.2)
+ actioncable (= 5.2.2)
+ actionmailer (= 5.2.2)
+ actionpack (= 5.2.2)
+ actionview (= 5.2.2)
+ activejob (= 5.2.2)
+ activemodel (= 5.2.2)
+ activerecord (= 5.2.2)
+ activestorage (= 5.2.2)
+ activesupport (= 5.2.2)
+ bundler (>= 1.3.0)
+ railties (= 5.2.2)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.0.4)
+ loofah (~> 2.2, >= 2.2.2)
+ railties (5.2.2)
+ actionpack (= 5.2.2)
+ activesupport (= 5.2.2)
+ method_source
+ rake (>= 0.8.7)
+ thor (>= 0.19.0, < 2.0)
+ rake (12.3.2)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
+ regexp_parser (1.3.0)
+ ruby_dep (1.5.0)
+ rubyzip (1.2.2)
+ sass (3.7.3)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.7)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
+ selenium-webdriver (3.141.0)
+ childprocess (~> 0.5)
+ rubyzip (~> 1.2, >= 1.2.2)
+ spring (2.0.2)
+ activesupport (>= 4.2)
+ spring-watcher-listen (2.0.1)
+ listen (>= 2.7, < 4.0)
+ spring (>= 1.2, < 3.0)
+ sprockets (3.7.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ sqlite3 (1.3.13)
+ thor (0.20.3)
+ thread_safe (0.3.6)
+ tilt (2.0.9)
+ turbolinks (5.2.0)
+ turbolinks-source (~> 5.2)
+ turbolinks-source (5.2.0)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ uglifier (4.1.20)
+ execjs (>= 0.3.0, < 3)
+ web-console (3.7.0)
+ actionview (>= 5.0)
+ activemodel (>= 5.0)
+ bindex (>= 0.4.0)
+ railties (>= 5.0)
+ websocket-driver (0.7.0)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.3)
+ xpath (3.2.0)
+ nokogiri (~> 1.8)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bootsnap (>= 1.1.0)
+ byebug
+ capybara (>= 2.15)
+ chromedriver-helper
+ coffee-rails (~> 4.2)
+ jbuilder (~> 2.5)
+ listen (>= 3.0.5, < 3.2)
+ puma (~> 3.11)
+ rails (~> 5.2.2)
+ sass-rails (~> 5.0)
+ selenium-webdriver
+ spring
+ spring-watcher-listen (~> 2.0.0)
+ sqlite3 (~> 1.3.6)
+ turbolinks (~> 5)
+ tzinfo-data
+ uglifier (>= 1.3.0)
+ web-console (>= 3.3.0)
+
+RUBY VERSION
+ ruby 2.6.1p33
+
+BUNDLED WITH
+ 1.17.3
diff --git a/library/README.md b/library/README.md
new file mode 100644
index 0000000..7db80e4
--- /dev/null
+++ b/library/README.md
@@ -0,0 +1,24 @@
+# README
+
+This README would normally document whatever steps are necessary to get the
+application up and running.
+
+Things you may want to cover:
+
+* Ruby version
+
+* System dependencies
+
+* Configuration
+
+* Database creation
+
+* Database initialization
+
+* How to run the test suite
+
+* Services (job queues, cache servers, search engines, etc.)
+
+* Deployment instructions
+
+* ...
diff --git a/library/Rakefile b/library/Rakefile
new file mode 100644
index 0000000..e85f913
--- /dev/null
+++ b/library/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative 'config/application'
+
+Rails.application.load_tasks
diff --git a/library/app/assets/config/manifest.js b/library/app/assets/config/manifest.js
new file mode 100644
index 0000000..b16e53d
--- /dev/null
+++ b/library/app/assets/config/manifest.js
@@ -0,0 +1,3 @@
+//= link_tree ../images
+//= link_directory ../javascripts .js
+//= link_directory ../stylesheets .css
diff --git a/library/app/assets/images/.keep b/library/app/assets/images/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/app/assets/javascripts/application.js b/library/app/assets/javascripts/application.js
new file mode 100644
index 0000000..82e6f0f
--- /dev/null
+++ b/library/app/assets/javascripts/application.js
@@ -0,0 +1,16 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
+// vendor/assets/javascripts directory can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// compiled file. JavaScript code in this file should be added after the last require_* statement.
+//
+// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
+// about supported directives.
+//
+//= require rails-ujs
+//= require activestorage
+//= require turbolinks
+//= require_tree .
diff --git a/library/app/assets/javascripts/cable.js b/library/app/assets/javascripts/cable.js
new file mode 100644
index 0000000..739aa5f
--- /dev/null
+++ b/library/app/assets/javascripts/cable.js
@@ -0,0 +1,13 @@
+// Action Cable provides the framework to deal with WebSockets in Rails.
+// You can generate new channels where WebSocket features live using the `rails generate channel` command.
+//
+//= require action_cable
+//= require_self
+//= require_tree ./channels
+
+(function() {
+ this.App || (this.App = {});
+
+ App.cable = ActionCable.createConsumer();
+
+}).call(this);
diff --git a/library/app/assets/javascripts/channels/.keep b/library/app/assets/javascripts/channels/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/app/assets/stylesheets/application.css b/library/app/assets/stylesheets/application.css
new file mode 100644
index 0000000..d05ea0f
--- /dev/null
+++ b/library/app/assets/stylesheets/application.css
@@ -0,0 +1,15 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
diff --git a/library/app/channels/application_cable/channel.rb b/library/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..d672697
--- /dev/null
+++ b/library/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/library/app/channels/application_cable/connection.rb b/library/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..0ff5442
--- /dev/null
+++ b/library/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/library/app/controllers/application_controller.rb b/library/app/controllers/application_controller.rb
new file mode 100644
index 0000000..09705d1
--- /dev/null
+++ b/library/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
diff --git a/library/app/controllers/books_controller.rb b/library/app/controllers/books_controller.rb
new file mode 100644
index 0000000..78481b4
--- /dev/null
+++ b/library/app/controllers/books_controller.rb
@@ -0,0 +1,55 @@
+class BooksController < ApplicationController
+
+ def index
+
+
+ @books = Book.all
+
+ end
+
+ def show
+
+ @book = Book.find(params[:id])
+ end
+
+ def destroy
+ @book = Book.find(params[:id])
+ @book.destroy
+ redirect_to books_path
+ end
+
+ def new
+
+ # @book = Book.find(params[:id])
+ end
+
+ def edit
+ @book = Book.find(params[:id])
+
+ end
+
+ def update
+ @book = Book.find(params[:id])
+ if @book.update(book_params)
+ redirect_to books_path
+ else
+ render 'edit'
+
+ end
+ end
+
+
+ def create
+
+ @book = Book.new(book_params)
+ if @book.save
+ redirect_to books_path
+ else
+ render action: "new"
+ end
+ end
+
+ def book_params
+ params.require(:book).permit(:title, :author)
+ end
+end
\ No newline at end of file
diff --git a/library/app/controllers/concerns/.keep b/library/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/app/controllers/ingredients_controller.rb b/library/app/controllers/ingredients_controller.rb
new file mode 100644
index 0000000..3c67acd
--- /dev/null
+++ b/library/app/controllers/ingredients_controller.rb
@@ -0,0 +1,15 @@
+class IngredientsController < ApplicationController
+
+ def index
+
+
+ @ingredients = Ingredient.all
+
+ end
+
+ def show
+
+ @ingredient = Ingredient.find(params[:id])
+
+ end
+end
\ No newline at end of file
diff --git a/library/app/controllers/movies_controller.rb b/library/app/controllers/movies_controller.rb
new file mode 100644
index 0000000..d8717c6
--- /dev/null
+++ b/library/app/controllers/movies_controller.rb
@@ -0,0 +1,54 @@
+class MoviesController < ApplicationController
+
+ def index
+
+
+ @movies = Movie.all
+
+ end
+
+ def show
+
+ @movie = Movie.find(params[:id])
+ end
+
+ def destroy
+ @movie = Movie.find(params[:id])
+ @movie.destroy
+ redirect_to movies_path
+ end
+
+ def new
+
+ # @movie = Movie.find(params[:id])
+ end
+ def edit
+ @movie= Movie.find(params[:id])
+
+ end
+
+ def update
+ @movie = Movie.find(params[:id])
+ if @movie.update(movie_params)
+ redirect_to movies_path
+ else
+ render 'edit'
+
+ end
+ end
+
+ def create
+
+ @movie = Movie.new(movie_params)
+ if @movie.save
+ redirect_to movies_path
+ else
+ render action: "new"
+ end
+ end
+
+
+ def movie_params
+ params.require(:movie).permit(:director, :title, :rating)
+ end
+end
diff --git a/library/app/helpers/application_helper.rb b/library/app/helpers/application_helper.rb
new file mode 100644
index 0000000..de6be79
--- /dev/null
+++ b/library/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/library/app/jobs/application_job.rb b/library/app/jobs/application_job.rb
new file mode 100644
index 0000000..a009ace
--- /dev/null
+++ b/library/app/jobs/application_job.rb
@@ -0,0 +1,2 @@
+class ApplicationJob < ActiveJob::Base
+end
diff --git a/library/app/mailers/application_mailer.rb b/library/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..286b223
--- /dev/null
+++ b/library/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: 'from@example.com'
+ layout 'mailer'
+end
diff --git a/library/app/models/application_record.rb b/library/app/models/application_record.rb
new file mode 100644
index 0000000..10a4cba
--- /dev/null
+++ b/library/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+end
diff --git a/library/app/models/book.rb b/library/app/models/book.rb
new file mode 100644
index 0000000..99c6134
--- /dev/null
+++ b/library/app/models/book.rb
@@ -0,0 +1,5 @@
+class Book < ApplicationRecord
+
+
+
+end
\ No newline at end of file
diff --git a/library/app/models/concerns/.keep b/library/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/app/models/ingredient.rb b/library/app/models/ingredient.rb
new file mode 100644
index 0000000..d11973e
--- /dev/null
+++ b/library/app/models/ingredient.rb
@@ -0,0 +1,5 @@
+class Ingredient < ApplicationRecord
+
+
+
+end
\ No newline at end of file
diff --git a/library/app/models/movie.rb b/library/app/models/movie.rb
new file mode 100644
index 0000000..9d89d5c
--- /dev/null
+++ b/library/app/models/movie.rb
@@ -0,0 +1,5 @@
+class Movie < ApplicationRecord
+
+
+
+end
\ No newline at end of file
diff --git a/library/app/views/books/edit.html.erb b/library/app/views/books/edit.html.erb
new file mode 100644
index 0000000..294b253
--- /dev/null
+++ b/library/app/views/books/edit.html.erb
@@ -0,0 +1,20 @@
+Edit a book
+
+ <%= link_to 'All Books' , books_path %>
+
+<%= form_for @book, local:true do |form| %>
+
+
+ <%= form.text_field :title %>
+
+
+
+ <%= form.text_field :author %>
+
+
+
+ <%= form.submit %>
+
+
+
+ <% end %>
\ No newline at end of file
diff --git a/library/app/views/books/index.html.erb b/library/app/views/books/index.html.erb
new file mode 100644
index 0000000..2f47b85
--- /dev/null
+++ b/library/app/views/books/index.html.erb
@@ -0,0 +1,20 @@
+ HOLLA
+
+ <%= link_to 'Create new book' , new_book_path %>
+
+<% @books.each do |book| %>
+
+<%= book.title %>
+
+
+ <%= link_to 'View' , book_path(book) %>
+ <%= link_to 'Edit' , edit_book_path(book) %>
+
+
+ <%= link_to 'Delete',
+book_path(book),
+method: :delete,
+data: { confirm: 'Are you sure you want to delete item !'} %>
+
+<% end %>
+
diff --git a/library/app/views/books/new.html.erb b/library/app/views/books/new.html.erb
new file mode 100644
index 0000000..3eefb90
--- /dev/null
+++ b/library/app/views/books/new.html.erb
@@ -0,0 +1,20 @@
+Create a new book
+
+ <%= link_to 'All Books' , books_path %>
+
+<%= form_with scope: :book, url:'/books' , local:true do |form| %>
+
+
+ <%= form.text_field :title %>
+
+
+
+ <%= form.text_field :author %>
+
+
+
+ <%= form.submit %>
+
+
+
+ <% end %>
\ No newline at end of file
diff --git a/library/app/views/books/show.html.erb b/library/app/views/books/show.html.erb
new file mode 100644
index 0000000..0541333
--- /dev/null
+++ b/library/app/views/books/show.html.erb
@@ -0,0 +1,13 @@
+
+
+
+- <%= @book.title %>
+
+
+
+
+ - <%= @book.author %>
+
+
+
+ <%= link_to 'View All Book' , books_path %>
\ No newline at end of file
diff --git a/library/app/views/ingredients/index.html.erb b/library/app/views/ingredients/index.html.erb
new file mode 100644
index 0000000..73dfc78
--- /dev/null
+++ b/library/app/views/ingredients/index.html.erb
@@ -0,0 +1,11 @@
+ Hi
+
+
+<% @ingredients.each do |ingredient| %>
+
+<%= ingredient.name %>
+
+
+ <%= link_to 'View' , ingredient_path(ingredient) %>
+
+<% end %>
diff --git a/library/app/views/ingredients/show.html.erb b/library/app/views/ingredients/show.html.erb
new file mode 100644
index 0000000..99e56c9
--- /dev/null
+++ b/library/app/views/ingredients/show.html.erb
@@ -0,0 +1,12 @@
+
+
+
+- Name: <%= @ingredient.name %>
+- Unit: <%= @ingredient.unit %>
+- Amount: <%= @ingredient.amount %>
+- Purchased_on: <%= @ingredient.purchased_on %>
+- Is_rotten: <%= @ingredient.is_rotten %>
+
+
+
+ <%= link_to 'View All Ingredient' , ingredients_path %>
\ No newline at end of file
diff --git a/library/app/views/layouts/application.html.erb b/library/app/views/layouts/application.html.erb
new file mode 100644
index 0000000..871b419
--- /dev/null
+++ b/library/app/views/layouts/application.html.erb
@@ -0,0 +1,15 @@
+
+
+
+ Library
+ <%= csrf_meta_tags %>
+ <%= csp_meta_tag %>
+
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
+
+
+
+ <%= yield %>
+
+
diff --git a/library/app/views/layouts/mailer.html.erb b/library/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000..cbd34d2
--- /dev/null
+++ b/library/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/library/app/views/layouts/mailer.text.erb b/library/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000..37f0bdd
--- /dev/null
+++ b/library/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/library/app/views/movies/edit.html.erb b/library/app/views/movies/edit.html.erb
new file mode 100644
index 0000000..a48903b
--- /dev/null
+++ b/library/app/views/movies/edit.html.erb
@@ -0,0 +1,25 @@
+Edit a movie
+
+ <%= link_to 'All Movies' , movies_path %>
+
+<%= form_for @movie, local:true do |form| %>
+
+ Director:
+ <%= form.text_field :director %>
+
+
+ Title:
+ <%= form.text_field :title %>
+
+
Rating:
+ <%= form.text_field :rating %>
+
+
+
+
+
+ <%= form.submit %>
+
+
+
+ <% end %>
\ No newline at end of file
diff --git a/library/app/views/movies/index.html.erb b/library/app/views/movies/index.html.erb
new file mode 100644
index 0000000..b0a3a07
--- /dev/null
+++ b/library/app/views/movies/index.html.erb
@@ -0,0 +1,18 @@
+ HOLLA
+
+ <%= link_to 'Create new movie' , new_movie_path %>
+
+<% @movies.each do |movie| %>
+
+<%= movie.title %>
+
+
+ <%= link_to 'View' , movie_path(movie) %>
+ <%= link_to 'Edit' , edit_movie_path(movie) %>
+
+ <%= link_to 'Delete',
+book_path(movie),
+method: :delete,
+data: { confirm: 'Are you sure you want to delete item !'} %>
+
+<% end %>
diff --git a/library/app/views/movies/new.html.erb b/library/app/views/movies/new.html.erb
new file mode 100644
index 0000000..78e1463
--- /dev/null
+++ b/library/app/views/movies/new.html.erb
@@ -0,0 +1,25 @@
+Create a new movie
+
+ <%= link_to 'All Movies' , movies_path %>
+
+<%= form_with scope: :movie, url:'/movies' , local:true do |form| %>
+
+ Director:
+ <%= form.text_field :director %>
+
+
+ Title:
+ <%= form.text_field :title %>
+
+
Rating:
+ <%= form.text_field :rating %>
+
+
+
+
+
+ <%= form.submit %>
+
+
+
+ <% end %>
\ No newline at end of file
diff --git a/library/app/views/movies/show.html.erb b/library/app/views/movies/show.html.erb
new file mode 100644
index 0000000..5a6ec3a
--- /dev/null
+++ b/library/app/views/movies/show.html.erb
@@ -0,0 +1,10 @@
+
+
+
+- Title: <%= @movie.title %>
+- Director: <%= @movie.director %>
+- Rating: <%= @movie.rating %>
+
+
+
+ <%= link_to 'View All Movie' , movies_path %>
\ No newline at end of file
diff --git a/library/bin/bundle b/library/bin/bundle
new file mode 100755
index 0000000..f19acf5
--- /dev/null
+++ b/library/bin/bundle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/library/bin/rails b/library/bin/rails
new file mode 100755
index 0000000..0739660
--- /dev/null
+++ b/library/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/library/bin/rake b/library/bin/rake
new file mode 100755
index 0000000..1724048
--- /dev/null
+++ b/library/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/library/bin/setup b/library/bin/setup
new file mode 100755
index 0000000..94fd4d7
--- /dev/null
+++ b/library/bin/setup
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a starting point to setup your application.
+ # Add necessary setup steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?('config/database.yml')
+ # cp 'config/database.yml.sample', 'config/database.yml'
+ # end
+
+ puts "\n== Preparing database =="
+ system! 'bin/rails db:setup'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/library/bin/update b/library/bin/update
new file mode 100755
index 0000000..58bfaed
--- /dev/null
+++ b/library/bin/update
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+include FileUtils
+
+# path to your application root.
+APP_ROOT = File.expand_path('..', __dir__)
+
+def system!(*args)
+ system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+ # This script is a way to update your development environment automatically.
+ # Add necessary update steps to this file.
+
+ puts '== Installing dependencies =='
+ system! 'gem install bundler --conservative'
+ system('bundle check') || system!('bundle install')
+
+ # Install JavaScript dependencies if using Yarn
+ # system('bin/yarn')
+
+ puts "\n== Updating database =="
+ system! 'bin/rails db:migrate'
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! 'bin/rails log:clear tmp:clear'
+
+ puts "\n== Restarting application server =="
+ system! 'bin/rails restart'
+end
diff --git a/library/bin/yarn b/library/bin/yarn
new file mode 100755
index 0000000..460dd56
--- /dev/null
+++ b/library/bin/yarn
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path('..', __dir__)
+Dir.chdir(APP_ROOT) do
+ begin
+ exec "yarnpkg", *ARGV
+ rescue Errno::ENOENT
+ $stderr.puts "Yarn executable was not detected in the system."
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
+ exit 1
+ end
+end
diff --git a/library/config.ru b/library/config.ru
new file mode 100644
index 0000000..f7ba0b5
--- /dev/null
+++ b/library/config.ru
@@ -0,0 +1,5 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative 'config/environment'
+
+run Rails.application
diff --git a/library/config/application.rb b/library/config/application.rb
new file mode 100644
index 0000000..493beb8
--- /dev/null
+++ b/library/config/application.rb
@@ -0,0 +1,19 @@
+require_relative 'boot'
+
+require 'rails/all'
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Library
+ class Application < Rails::Application
+ # Initialize configuration defaults for originally generated Rails version.
+ config.load_defaults 5.2
+
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration can go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded after loading
+ # the framework and any gems in your application.
+ end
+end
diff --git a/library/config/boot.rb b/library/config/boot.rb
new file mode 100644
index 0000000..b9e460c
--- /dev/null
+++ b/library/config/boot.rb
@@ -0,0 +1,4 @@
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+
+require 'bundler/setup' # Set up gems listed in the Gemfile.
+require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
diff --git a/library/config/cable.yml b/library/config/cable.yml
new file mode 100644
index 0000000..8e41465
--- /dev/null
+++ b/library/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: async
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: library_production
diff --git a/library/config/credentials.yml.enc b/library/config/credentials.yml.enc
new file mode 100644
index 0000000..1b2fccd
--- /dev/null
+++ b/library/config/credentials.yml.enc
@@ -0,0 +1 @@
+Uv6Zvm55zRRSshPx8i5r7e28kP55cA1CbHyt/314l8peTxCXaqNoaRuAaRnpZeOblIsNHp+Iv0X6R/GfP1VQpS6wWmfrp8iemUMAPe/2fFsb7GT1ywWwGqO9fXJdDnHrE2UHDRjs2d4kPeMdkTklELWfSu2VcBwWtKQvDuWDjO2LTyOupwscLkMoyoEidMe7j3A+aT5pb4LNVZoqW2urIeNMFd2dXbLOlLI27MwxAcMHgHNubVJ5XMXTcLBq+wLzebGHd2klaBWo/kJtWHcFe3cFIAFRYzjEJs+6IGbvEMmzh+d5JZKRUGEFT40eI5+5eGVGgUir9ssIjyz/tkL7BJlgTMm8e8DPEl139SDrNQMC5bIaMRvFGm3OkzJh1RdByaWJFpaZc1kbha3dyy+R0m4WSSvQn+uc0Iim--/+UxIvF+DMr5dQE3--rPLGmIaeQPizIceTd5TWqQ==
\ No newline at end of file
diff --git a/library/config/database.yml b/library/config/database.yml
new file mode 100644
index 0000000..0d02f24
--- /dev/null
+++ b/library/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+#
+default: &default
+ adapter: sqlite3
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+ timeout: 5000
+
+development:
+ <<: *default
+ database: db/development.sqlite3
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: db/test.sqlite3
+
+production:
+ <<: *default
+ database: db/production.sqlite3
diff --git a/library/config/environment.rb b/library/config/environment.rb
new file mode 100644
index 0000000..426333b
--- /dev/null
+++ b/library/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative 'application'
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/library/config/environments/development.rb b/library/config/environments/development.rb
new file mode 100644
index 0000000..1311e3e
--- /dev/null
+++ b/library/config/environments/development.rb
@@ -0,0 +1,61 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
+ config.action_controller.perform_caching = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # Debug mode disables concatenation and preprocessing of assets.
+ # This option may cause significant delays in view rendering with a large
+ # number of complex assets.
+ config.assets.debug = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+
+ # Use an evented file watcher to asynchronously detect changes in source code,
+ # routes, locales, etc. This feature depends on the listen gem.
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+end
diff --git a/library/config/environments/production.rb b/library/config/environments/production.rb
new file mode 100644
index 0000000..7dec21a
--- /dev/null
+++ b/library/config/environments/production.rb
@@ -0,0 +1,94 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.cache_classes = true
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Disable serving static files from the `/public` folder by default since
+ # Apache or NGINX already handles this.
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
+
+ # Compress JavaScripts and CSS.
+ config.assets.js_compressor = :uglifier
+ # config.assets.css_compressor = :sass
+
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.action_controller.asset_host = 'http://assets.example.com'
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options)
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = 'wss://example.com/cable'
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # Use the lowest log level to ensure availability of diagnostic information
+ # when problems arise.
+ config.log_level = :debug
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment)
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "library_#{Rails.env}"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners.
+ config.active_support.deprecation = :notify
+
+ # Use default logging formatter so that PID and timestamp are not suppressed.
+ config.log_formatter = ::Logger::Formatter.new
+
+ # Use a different logger for distributed setups.
+ # require 'syslog/logger'
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
+
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
+ logger = ActiveSupport::Logger.new(STDOUT)
+ logger.formatter = config.log_formatter
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
+ end
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+end
diff --git a/library/config/environments/test.rb b/library/config/environments/test.rb
new file mode 100644
index 0000000..0a38fd3
--- /dev/null
+++ b/library/config/environments/test.rb
@@ -0,0 +1,46 @@
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Do not eager load code on boot. This avoids loading your whole application
+ # just for the purpose of running a single test. If you are using a tool that
+ # preloads Rails for running tests, you may have to set it to true.
+ config.eager_load = false
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates.
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raises error for missing translations
+ # config.action_view.raise_on_missing_translations = true
+end
diff --git a/library/config/initializers/application_controller_renderer.rb b/library/config/initializers/application_controller_renderer.rb
new file mode 100644
index 0000000..89d2efa
--- /dev/null
+++ b/library/config/initializers/application_controller_renderer.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# ActiveSupport::Reloader.to_prepare do
+# ApplicationController.renderer.defaults.merge!(
+# http_host: 'example.org',
+# https: false
+# )
+# end
diff --git a/library/config/initializers/assets.rb b/library/config/initializers/assets.rb
new file mode 100644
index 0000000..4b828e8
--- /dev/null
+++ b/library/config/initializers/assets.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+# Add Yarn node_modules folder to the asset load path.
+Rails.application.config.assets.paths << Rails.root.join('node_modules')
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/library/config/initializers/backtrace_silencers.rb b/library/config/initializers/backtrace_silencers.rb
new file mode 100644
index 0000000..59385cd
--- /dev/null
+++ b/library/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/library/config/initializers/content_security_policy.rb b/library/config/initializers/content_security_policy.rb
new file mode 100644
index 0000000..d3bcaa5
--- /dev/null
+++ b/library/config/initializers/content_security_policy.rb
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy
+# For further information see the following documentation
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
+
+# Rails.application.config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+
+# If you are using UJS then enable automatic nonce generation
+# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
+
+# Report CSP violations to a specified URI
+# For further information see the following documentation:
+# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
+# Rails.application.config.content_security_policy_report_only = true
diff --git a/library/config/initializers/cookies_serializer.rb b/library/config/initializers/cookies_serializer.rb
new file mode 100644
index 0000000..5a6a32d
--- /dev/null
+++ b/library/config/initializers/cookies_serializer.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Specify a serializer for the signed and encrypted cookie jars.
+# Valid options are :json, :marshal, and :hybrid.
+Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/library/config/initializers/filter_parameter_logging.rb b/library/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..4a994e1
--- /dev/null
+++ b/library/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure sensitive parameters which will be filtered from the log file.
+Rails.application.config.filter_parameters += [:password]
diff --git a/library/config/initializers/inflections.rb b/library/config/initializers/inflections.rb
new file mode 100644
index 0000000..ac033bf
--- /dev/null
+++ b/library/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/library/config/initializers/mime_types.rb b/library/config/initializers/mime_types.rb
new file mode 100644
index 0000000..dc18996
--- /dev/null
+++ b/library/config/initializers/mime_types.rb
@@ -0,0 +1,4 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
diff --git a/library/config/initializers/wrap_parameters.rb b/library/config/initializers/wrap_parameters.rb
new file mode 100644
index 0000000..bbfc396
--- /dev/null
+++ b/library/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# To enable root element in JSON for ActiveRecord objects.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = true
+# end
diff --git a/library/config/locales/en.yml b/library/config/locales/en.yml
new file mode 100644
index 0000000..decc5a8
--- /dev/null
+++ b/library/config/locales/en.yml
@@ -0,0 +1,33 @@
+# Files in the config/locales directory are used for internationalization
+# and are automatically loaded by Rails. If you want to use locales other
+# than English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t 'hello'
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t('hello') %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# The following keys must be escaped otherwise they will not be retrieved by
+# the default I18n backend:
+#
+# true, false, on, off, yes, no
+#
+# Instead, surround them with single quotes.
+#
+# en:
+# 'true': 'foo'
+#
+# To learn more, please read the Rails Internationalization guide
+# available at http://guides.rubyonrails.org/i18n.html.
+
+en:
+ hello: "Hello world"
diff --git a/library/config/puma.rb b/library/config/puma.rb
new file mode 100644
index 0000000..a5eccf8
--- /dev/null
+++ b/library/config/puma.rb
@@ -0,0 +1,34 @@
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+#
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads threads_count, threads_count
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+#
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+#
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the number of `workers` to boot in clustered mode.
+# Workers are forked webserver processes. If using threads and workers together
+# the concurrency of the application would be max `threads` * `workers`.
+# Workers do not work on JRuby or Windows (both of which do not support
+# processes).
+#
+# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
+
+# Use the `preload_app!` method when specifying a `workers` number.
+# This directive tells Puma to first boot the application and load code
+# before forking the application. This takes advantage of Copy On Write
+# process behavior so workers use less memory.
+#
+# preload_app!
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/library/config/routes.rb b/library/config/routes.rb
new file mode 100644
index 0000000..a935920
--- /dev/null
+++ b/library/config/routes.rb
@@ -0,0 +1,23 @@
+Rails.application.routes.draw do
+ # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+ get '/books' => "books#index" , as:'books' #books_path
+ get '/books/new' => "books#new" , as: 'new_book'
+ get '/books/:id/edit' => "books#edit" , as:'edit_book'
+ get '/books/:id' => "books#show" , as: 'book' #book_path(book)
+ get '/movies' => "movies#index" , as: 'movies'
+ get '/movies/new' => "movies#new" , as: 'new_movie'
+ get '/movies/:id/edit' => "movies#edit" , as:'edit_movie'
+ get '/movies/:id' => "movies#show" , as: 'movie'
+ get '/ingredients' => "ingredients#index" , as: 'ingredients'
+ get '/ingredients/:id' => "ingredients#show" , as: 'ingredient'
+
+
+ post '/books' => "books#create"
+ post '/movies' => "movies#create"
+ patch '/books/:id' => "books#update"
+ patch '/movies/:id' => "movies#update"
+ delete '/books/:id' => "books#destroy"
+ delete '/movies/:id' => "movies#destroy"
+
+
+end
diff --git a/library/config/spring.rb b/library/config/spring.rb
new file mode 100644
index 0000000..9fa7863
--- /dev/null
+++ b/library/config/spring.rb
@@ -0,0 +1,6 @@
+%w[
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+].each { |path| Spring.watch(path) }
diff --git a/library/config/storage.yml b/library/config/storage.yml
new file mode 100644
index 0000000..d32f76e
--- /dev/null
+++ b/library/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket
+
+# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/library/db/migrate/000_create_books.rb b/library/db/migrate/000_create_books.rb
new file mode 100644
index 0000000..9eedecf
--- /dev/null
+++ b/library/db/migrate/000_create_books.rb
@@ -0,0 +1,11 @@
+class CreateBooks < ActiveRecord::Migration[5.2]
+ def change
+ create_table :books do |t|
+
+ t.string :title
+ t.string :author
+ t.timestamps
+
+ end
+ end
+ end
\ No newline at end of file
diff --git a/library/db/migrate/001_create_movies.rb b/library/db/migrate/001_create_movies.rb
new file mode 100644
index 0000000..d40fed3
--- /dev/null
+++ b/library/db/migrate/001_create_movies.rb
@@ -0,0 +1,10 @@
+class CreateMovies < ActiveRecord::Migration[5.2]
+ def change
+ create_table :movies do |t|
+ t.string :director
+ t.string :title
+ t.integer :rating
+ t.timestamps
+ end
+ end
+end
\ No newline at end of file
diff --git a/library/db/migrate/002_create_ingredients.rb b/library/db/migrate/002_create_ingredients.rb
new file mode 100644
index 0000000..97397e9
--- /dev/null
+++ b/library/db/migrate/002_create_ingredients.rb
@@ -0,0 +1,13 @@
+class CreateIngredients < ActiveRecord::Migration[5.2]
+ def change
+ create_table :ingredients do |t|
+ t.string :name
+ t.string :unit
+ t.integer :amount
+ t.date :purchased_on
+ t.boolean :is_rotten
+ t.timestamps
+
+ end
+ end
+ end
\ No newline at end of file
diff --git a/library/db/schema.rb b/library/db/schema.rb
new file mode 100644
index 0000000..cfa93ec
--- /dev/null
+++ b/library/db/schema.rb
@@ -0,0 +1,40 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 2) do
+
+ create_table "books", force: :cascade do |t|
+ t.string "title"
+ t.string "author"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "ingredients", force: :cascade do |t|
+ t.string "name"
+ t.string "unit"
+ t.integer "amount"
+ t.date "purchased_on"
+ t.boolean "is_rotten"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "movies", force: :cascade do |t|
+ t.string "director"
+ t.string "title"
+ t.integer "rating"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/library/db/seeds.rb b/library/db/seeds.rb
new file mode 100644
index 0000000..1beea2a
--- /dev/null
+++ b/library/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
+#
+# Examples:
+#
+# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
+# Character.create(name: 'Luke', movie: movies.first)
diff --git a/library/lib/assets/.keep b/library/lib/assets/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/lib/tasks/.keep b/library/lib/tasks/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/log/.keep b/library/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/package.json b/library/package.json
new file mode 100644
index 0000000..7562efd
--- /dev/null
+++ b/library/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "library",
+ "private": true,
+ "dependencies": {}
+}
diff --git a/library/public/404.html b/library/public/404.html
new file mode 100644
index 0000000..2be3af2
--- /dev/null
+++ b/library/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+ The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/library/public/422.html b/library/public/422.html
new file mode 100644
index 0000000..c08eac0
--- /dev/null
+++ b/library/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+ The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/library/public/500.html b/library/public/500.html
new file mode 100644
index 0000000..78a030a
--- /dev/null
+++ b/library/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+ We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/library/public/apple-touch-icon-precomposed.png b/library/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000..e69de29
diff --git a/library/public/apple-touch-icon.png b/library/public/apple-touch-icon.png
new file mode 100644
index 0000000..e69de29
diff --git a/library/public/favicon.ico b/library/public/favicon.ico
new file mode 100644
index 0000000..e69de29
diff --git a/library/public/robots.txt b/library/public/robots.txt
new file mode 100644
index 0000000..37b576a
--- /dev/null
+++ b/library/public/robots.txt
@@ -0,0 +1 @@
+# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/library/storage/.keep b/library/storage/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/application_system_test_case.rb b/library/test/application_system_test_case.rb
new file mode 100644
index 0000000..d19212a
--- /dev/null
+++ b/library/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
+end
diff --git a/library/test/controllers/.keep b/library/test/controllers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/fixtures/.keep b/library/test/fixtures/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/fixtures/files/.keep b/library/test/fixtures/files/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/helpers/.keep b/library/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/integration/.keep b/library/test/integration/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/mailers/.keep b/library/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/models/.keep b/library/test/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/system/.keep b/library/test/system/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/test/test_helper.rb b/library/test/test_helper.rb
new file mode 100644
index 0000000..3ab84e3
--- /dev/null
+++ b/library/test/test_helper.rb
@@ -0,0 +1,10 @@
+ENV['RAILS_ENV'] ||= 'test'
+require_relative '../config/environment'
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
diff --git a/library/tmp/.keep b/library/tmp/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/library/vendor/.keep b/library/vendor/.keep
new file mode 100644
index 0000000..e69de29
From cf6fbab0b6828ed85ab01b37eb5553b4df52f66b Mon Sep 17 00:00:00 2001
From: ceahmad
Date: Sun, 3 Mar 2019 22:57:36 +0300
Subject: [PATCH 2/3] Movies,Books,Ingredients"H.W",Paintings"H.W'
---
.../app/assets/javascripts/articles.coffee | 3 +
.../app/assets/javascripts/comments.coffee | 3 +
.../app/assets/javascripts/paintings.coffee | 3 +
library/app/assets/stylesheets/articles.scss | 3 +
library/app/assets/stylesheets/comments.scss | 3 +
library/app/assets/stylesheets/paintings.scss | 3 +
library/app/assets/stylesheets/scaffolds.scss | 84 +++++++++++++++++++
.../app/controllers/articles_controller.rb | 74 ++++++++++++++++
.../app/controllers/comments_controller.rb | 13 +++
.../app/controllers/paintings_controller.rb | 74 ++++++++++++++++
library/app/helpers/articles_helper.rb | 2 +
library/app/helpers/comments_helper.rb | 2 +
library/app/helpers/paintings_helper.rb | 2 +
library/app/models/article.rb | 6 ++
library/app/models/comment.rb | 4 +
library/app/models/painting.rb | 2 +
.../app/views/articles/_article.json.jbuilder | 2 +
library/app/views/articles/_form.html.erb | 27 ++++++
library/app/views/articles/edit.html.erb | 6 ++
library/app/views/articles/index.html.erb | 29 +++++++
.../app/views/articles/index.json.jbuilder | 1 +
library/app/views/articles/new.html.erb | 5 ++
library/app/views/articles/show.html.erb | 31 +++++++
library/app/views/articles/show.json.jbuilder | 1 +
library/app/views/paintings/_form.html.erb | 27 ++++++
.../views/paintings/_painting.json.jbuilder | 2 +
library/app/views/paintings/edit.html.erb | 6 ++
library/app/views/paintings/index.html.erb | 29 +++++++
.../app/views/paintings/index.json.jbuilder | 1 +
library/app/views/paintings/new.html.erb | 5 ++
library/app/views/paintings/show.html.erb | 14 ++++
.../app/views/paintings/show.json.jbuilder | 1 +
library/config/routes.rb | 39 +++++----
.../20190303122652_create_paintings.rb | 10 +++
.../migrate/20190303132522_create_articles.rb | 10 +++
.../migrate/20190303134138_create_comments.rb | 14 ++++
library/db/schema.rb | 25 +++++-
.../controllers/articles_controller_test.rb | 48 +++++++++++
.../controllers/comments_controller_test.rb | 7 ++
.../controllers/paintings_controller_test.rb | 48 +++++++++++
library/test/fixtures/articles.yml | 9 ++
library/test/fixtures/comments.yml | 9 ++
library/test/fixtures/paintings.yml | 9 ++
library/test/models/article_test.rb | 7 ++
library/test/models/comment_test.rb | 7 ++
library/test/models/painting_test.rb | 7 ++
library/test/system/articles_test.rb | 45 ++++++++++
library/test/system/paintings_test.rb | 45 ++++++++++
48 files changed, 790 insertions(+), 17 deletions(-)
create mode 100644 library/app/assets/javascripts/articles.coffee
create mode 100644 library/app/assets/javascripts/comments.coffee
create mode 100644 library/app/assets/javascripts/paintings.coffee
create mode 100644 library/app/assets/stylesheets/articles.scss
create mode 100644 library/app/assets/stylesheets/comments.scss
create mode 100644 library/app/assets/stylesheets/paintings.scss
create mode 100644 library/app/assets/stylesheets/scaffolds.scss
create mode 100644 library/app/controllers/articles_controller.rb
create mode 100644 library/app/controllers/comments_controller.rb
create mode 100644 library/app/controllers/paintings_controller.rb
create mode 100644 library/app/helpers/articles_helper.rb
create mode 100644 library/app/helpers/comments_helper.rb
create mode 100644 library/app/helpers/paintings_helper.rb
create mode 100644 library/app/models/article.rb
create mode 100644 library/app/models/comment.rb
create mode 100644 library/app/models/painting.rb
create mode 100644 library/app/views/articles/_article.json.jbuilder
create mode 100644 library/app/views/articles/_form.html.erb
create mode 100644 library/app/views/articles/edit.html.erb
create mode 100644 library/app/views/articles/index.html.erb
create mode 100644 library/app/views/articles/index.json.jbuilder
create mode 100644 library/app/views/articles/new.html.erb
create mode 100644 library/app/views/articles/show.html.erb
create mode 100644 library/app/views/articles/show.json.jbuilder
create mode 100644 library/app/views/paintings/_form.html.erb
create mode 100644 library/app/views/paintings/_painting.json.jbuilder
create mode 100644 library/app/views/paintings/edit.html.erb
create mode 100644 library/app/views/paintings/index.html.erb
create mode 100644 library/app/views/paintings/index.json.jbuilder
create mode 100644 library/app/views/paintings/new.html.erb
create mode 100644 library/app/views/paintings/show.html.erb
create mode 100644 library/app/views/paintings/show.json.jbuilder
create mode 100644 library/db/migrate/20190303122652_create_paintings.rb
create mode 100644 library/db/migrate/20190303132522_create_articles.rb
create mode 100644 library/db/migrate/20190303134138_create_comments.rb
create mode 100644 library/test/controllers/articles_controller_test.rb
create mode 100644 library/test/controllers/comments_controller_test.rb
create mode 100644 library/test/controllers/paintings_controller_test.rb
create mode 100644 library/test/fixtures/articles.yml
create mode 100644 library/test/fixtures/comments.yml
create mode 100644 library/test/fixtures/paintings.yml
create mode 100644 library/test/models/article_test.rb
create mode 100644 library/test/models/comment_test.rb
create mode 100644 library/test/models/painting_test.rb
create mode 100644 library/test/system/articles_test.rb
create mode 100644 library/test/system/paintings_test.rb
diff --git a/library/app/assets/javascripts/articles.coffee b/library/app/assets/javascripts/articles.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/library/app/assets/javascripts/articles.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/library/app/assets/javascripts/comments.coffee b/library/app/assets/javascripts/comments.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/library/app/assets/javascripts/comments.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/library/app/assets/javascripts/paintings.coffee b/library/app/assets/javascripts/paintings.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/library/app/assets/javascripts/paintings.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/library/app/assets/stylesheets/articles.scss b/library/app/assets/stylesheets/articles.scss
new file mode 100644
index 0000000..cca5487
--- /dev/null
+++ b/library/app/assets/stylesheets/articles.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the articles controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/library/app/assets/stylesheets/comments.scss b/library/app/assets/stylesheets/comments.scss
new file mode 100644
index 0000000..e730912
--- /dev/null
+++ b/library/app/assets/stylesheets/comments.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Comments controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/library/app/assets/stylesheets/paintings.scss b/library/app/assets/stylesheets/paintings.scss
new file mode 100644
index 0000000..a1e9084
--- /dev/null
+++ b/library/app/assets/stylesheets/paintings.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the paintings controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/library/app/assets/stylesheets/scaffolds.scss b/library/app/assets/stylesheets/scaffolds.scss
new file mode 100644
index 0000000..6045188
--- /dev/null
+++ b/library/app/assets/stylesheets/scaffolds.scss
@@ -0,0 +1,84 @@
+body {
+ background-color: #fff;
+ color: #333;
+ margin: 33px;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a {
+ color: #000;
+
+ &:visited {
+ color: #666;
+ }
+
+ &:hover {
+ color: #fff;
+ background-color: #000;
+ }
+}
+
+th {
+ padding-bottom: 5px;
+}
+
+td {
+ padding: 0 5px 7px;
+}
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px;
+ }
+}
+
+#notice {
+ color: green;
+}
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px 7px 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px -7px 0;
+ background-color: #c00;
+ color: #fff;
+ }
+
+ ul li {
+ font-size: 12px;
+ list-style: square;
+ }
+}
+
+label {
+ display: block;
+}
diff --git a/library/app/controllers/articles_controller.rb b/library/app/controllers/articles_controller.rb
new file mode 100644
index 0000000..4536962
--- /dev/null
+++ b/library/app/controllers/articles_controller.rb
@@ -0,0 +1,74 @@
+class ArticlesController < ApplicationController
+ before_action :set_article, only: [:show, :edit, :update, :destroy]
+
+ # GET /articles
+ # GET /articles.json
+ def index
+ @articles = Article.all
+ end
+
+ # GET /articles/1
+ # GET /articles/1.json
+ def show
+ end
+
+ # GET /articles/new
+ def new
+ @article = Article.new
+ end
+
+ # GET /articles/1/edit
+ def edit
+ end
+
+ # POST /articles
+ # POST /articles.json
+ def create
+ @article = Article.new(article_params)
+
+ respond_to do |format|
+ if @article.save
+ format.html { redirect_to @article, notice: 'Article was successfully created.' }
+ format.json { render :show, status: :created, location: @article }
+ else
+ format.html { render :new }
+ format.json { render json: @article.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /articles/1
+ # PATCH/PUT /articles/1.json
+ def update
+ respond_to do |format|
+ if @article.update(article_params)
+ format.html { redirect_to @article, notice: 'Article was successfully updated.' }
+ format.json { render :show, status: :ok, location: @article }
+ else
+ format.html { render :edit }
+ format.json { render json: @article.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /articles/1
+ # DELETE /articles/1.json
+ def destroy
+ @article.destroy
+ respond_to do |format|
+ format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_article
+ @article = Article.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def article_params
+ params.require(:article).permit(:title, :text)
+ end
+end
diff --git a/library/app/controllers/comments_controller.rb b/library/app/controllers/comments_controller.rb
new file mode 100644
index 0000000..c4e33de
--- /dev/null
+++ b/library/app/controllers/comments_controller.rb
@@ -0,0 +1,13 @@
+
+class CommentsController < ApplicationController
+ def create
+ @article = Article.find(params[:article_id])
+ @comment = @article.comments.create(comment_params)
+ redirect_to article_path(@article)
+ end
+
+ private
+ def comment_params
+ params.require(:comment).permit(:commenter, :body)
+ end
+ end
\ No newline at end of file
diff --git a/library/app/controllers/paintings_controller.rb b/library/app/controllers/paintings_controller.rb
new file mode 100644
index 0000000..d801653
--- /dev/null
+++ b/library/app/controllers/paintings_controller.rb
@@ -0,0 +1,74 @@
+class PaintingsController < ApplicationController
+ before_action :set_painting, only: [:show, :edit, :update, :destroy]
+
+ # GET /paintings
+ # GET /paintings.json
+ def index
+ @paintings = Painting.all
+ end
+
+ # GET /paintings/1
+ # GET /paintings/1.json
+ def show
+ end
+
+ # GET /paintings/new
+ def new
+ @painting = Painting.new
+ end
+
+ # GET /paintings/1/edit
+ def edit
+ end
+
+ # POST /paintings
+ # POST /paintings.json
+ def create
+ @painting = Painting.new(painting_params)
+
+ respond_to do |format|
+ if @painting.save
+ format.html { redirect_to @painting, notice: 'Painting was successfully created.' }
+ format.json { render :show, status: :created, location: @painting }
+ else
+ format.html { render :new }
+ format.json { render json: @painting.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /paintings/1
+ # PATCH/PUT /paintings/1.json
+ def update
+ respond_to do |format|
+ if @painting.update(painting_params)
+ format.html { redirect_to @painting, notice: 'Painting was successfully updated.' }
+ format.json { render :show, status: :ok, location: @painting }
+ else
+ format.html { render :edit }
+ format.json { render json: @painting.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /paintings/1
+ # DELETE /paintings/1.json
+ def destroy
+ @painting.destroy
+ respond_to do |format|
+ format.html { redirect_to paintings_url, notice: 'Painting was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_painting
+ @painting = Painting.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def painting_params
+ params.require(:painting).permit(:title, :artist)
+ end
+end
diff --git a/library/app/helpers/articles_helper.rb b/library/app/helpers/articles_helper.rb
new file mode 100644
index 0000000..2968277
--- /dev/null
+++ b/library/app/helpers/articles_helper.rb
@@ -0,0 +1,2 @@
+module ArticlesHelper
+end
diff --git a/library/app/helpers/comments_helper.rb b/library/app/helpers/comments_helper.rb
new file mode 100644
index 0000000..0ec9ca5
--- /dev/null
+++ b/library/app/helpers/comments_helper.rb
@@ -0,0 +1,2 @@
+module CommentsHelper
+end
diff --git a/library/app/helpers/paintings_helper.rb b/library/app/helpers/paintings_helper.rb
new file mode 100644
index 0000000..cfbc294
--- /dev/null
+++ b/library/app/helpers/paintings_helper.rb
@@ -0,0 +1,2 @@
+module PaintingsHelper
+end
diff --git a/library/app/models/article.rb b/library/app/models/article.rb
new file mode 100644
index 0000000..dcbf935
--- /dev/null
+++ b/library/app/models/article.rb
@@ -0,0 +1,6 @@
+
+class Article < ApplicationRecord
+ has_many :comments
+ validates :title, presence: true,
+ length: { minimum: 5 }
+ end
\ No newline at end of file
diff --git a/library/app/models/comment.rb b/library/app/models/comment.rb
new file mode 100644
index 0000000..6fe8eb5
--- /dev/null
+++ b/library/app/models/comment.rb
@@ -0,0 +1,4 @@
+
+class Comment < ApplicationRecord
+ belongs_to :article
+ end
diff --git a/library/app/models/painting.rb b/library/app/models/painting.rb
new file mode 100644
index 0000000..9daeb53
--- /dev/null
+++ b/library/app/models/painting.rb
@@ -0,0 +1,2 @@
+class Painting < ApplicationRecord
+end
diff --git a/library/app/views/articles/_article.json.jbuilder b/library/app/views/articles/_article.json.jbuilder
new file mode 100644
index 0000000..8f4e2e8
--- /dev/null
+++ b/library/app/views/articles/_article.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! article, :id, :title, :text, :created_at, :updated_at
+json.url article_url(article, format: :json)
diff --git a/library/app/views/articles/_form.html.erb b/library/app/views/articles/_form.html.erb
new file mode 100644
index 0000000..7ece14a
--- /dev/null
+++ b/library/app/views/articles/_form.html.erb
@@ -0,0 +1,27 @@
+<%= form_with(model: article, local: true) do |form| %>
+ <% if article.errors.any? %>
+
+
<%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:
+
+
+ <% article.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :title %>
+ <%= form.text_field :title %>
+
+
+
+ <%= form.label :text %>
+ <%= form.text_field :text %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/library/app/views/articles/edit.html.erb b/library/app/views/articles/edit.html.erb
new file mode 100644
index 0000000..65565c0
--- /dev/null
+++ b/library/app/views/articles/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Article
+
+<%= render 'form', article: @article %>
+
+<%= link_to 'Show', @article %> |
+<%= link_to 'Back', articles_path %>
diff --git a/library/app/views/articles/index.html.erb b/library/app/views/articles/index.html.erb
new file mode 100644
index 0000000..172e578
--- /dev/null
+++ b/library/app/views/articles/index.html.erb
@@ -0,0 +1,29 @@
+<%= notice %>
+
+Articles
+
+
+
+
+ Title |
+ Text |
+ |
+
+
+
+
+ <% @articles.each do |article| %>
+
+ <%= article.title %> |
+ <%= article.text %> |
+ <%= link_to 'Show', article %> |
+ <%= link_to 'Edit', edit_article_path(article) %> |
+ <%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Article', new_article_path %>
diff --git a/library/app/views/articles/index.json.jbuilder b/library/app/views/articles/index.json.jbuilder
new file mode 100644
index 0000000..4b23e9e
--- /dev/null
+++ b/library/app/views/articles/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @articles, partial: 'articles/article', as: :article
diff --git a/library/app/views/articles/new.html.erb b/library/app/views/articles/new.html.erb
new file mode 100644
index 0000000..056f863
--- /dev/null
+++ b/library/app/views/articles/new.html.erb
@@ -0,0 +1,5 @@
+New Article
+
+<%= render 'form', article: @article %>
+
+<%= link_to 'Back', articles_path %>
diff --git a/library/app/views/articles/show.html.erb b/library/app/views/articles/show.html.erb
new file mode 100644
index 0000000..54c1ff7
--- /dev/null
+++ b/library/app/views/articles/show.html.erb
@@ -0,0 +1,31 @@
+
+Comments
+<% @article.comments.each do |comment| %>
+
+ Commenter:
+ <%= comment.commenter %>
+
+
+
+ Comment:
+ <%= comment.body %>
+
+<% end %>
+
+Add a comment:
+<%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %>
+
+ <%= form.label :commenter %>
+ <%= form.text_field :commenter %>
+
+
+ <%= form.label :body %>
+ <%= form.text_area :body %>
+
+
+ <%= form.submit %>
+
+<% end %>
+
+<%= link_to 'Edit', edit_article_path(@article) %> |
+<%= link_to 'Back', articles_path %>
diff --git a/library/app/views/articles/show.json.jbuilder b/library/app/views/articles/show.json.jbuilder
new file mode 100644
index 0000000..dd1fbb4
--- /dev/null
+++ b/library/app/views/articles/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "articles/article", article: @article
diff --git a/library/app/views/paintings/_form.html.erb b/library/app/views/paintings/_form.html.erb
new file mode 100644
index 0000000..58887c0
--- /dev/null
+++ b/library/app/views/paintings/_form.html.erb
@@ -0,0 +1,27 @@
+<%= form_with(model: painting, local: true) do |form| %>
+ <% if painting.errors.any? %>
+
+
<%= pluralize(painting.errors.count, "error") %> prohibited this painting from being saved:
+
+
+ <% painting.errors.full_messages.each do |message| %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :title %>
+ <%= form.text_field :title %>
+
+
+
+ <%= form.label :artist %>
+ <%= form.text_field :artist %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/library/app/views/paintings/_painting.json.jbuilder b/library/app/views/paintings/_painting.json.jbuilder
new file mode 100644
index 0000000..aee1413
--- /dev/null
+++ b/library/app/views/paintings/_painting.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! painting, :id, :title, :artist, :created_at, :updated_at
+json.url painting_url(painting, format: :json)
diff --git a/library/app/views/paintings/edit.html.erb b/library/app/views/paintings/edit.html.erb
new file mode 100644
index 0000000..048e187
--- /dev/null
+++ b/library/app/views/paintings/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Painting
+
+<%= render 'form', painting: @painting %>
+
+<%= link_to 'Show', @painting %> |
+<%= link_to 'Back', paintings_path %>
diff --git a/library/app/views/paintings/index.html.erb b/library/app/views/paintings/index.html.erb
new file mode 100644
index 0000000..6076046
--- /dev/null
+++ b/library/app/views/paintings/index.html.erb
@@ -0,0 +1,29 @@
+<%= notice %>
+
+Paintings
+
+
+
+
+ Title |
+ Artist |
+ |
+
+
+
+
+ <% @paintings.each do |painting| %>
+
+ <%= painting.title %> |
+ <%= painting.artist %> |
+ <%= link_to 'Show', painting %> |
+ <%= link_to 'Edit', edit_painting_path(painting) %> |
+ <%= link_to 'Destroy', painting, method: :delete, data: { confirm: 'Are you sure?' } %> |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Painting', new_painting_path %>
diff --git a/library/app/views/paintings/index.json.jbuilder b/library/app/views/paintings/index.json.jbuilder
new file mode 100644
index 0000000..bf67c58
--- /dev/null
+++ b/library/app/views/paintings/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @paintings, partial: 'paintings/painting', as: :painting
diff --git a/library/app/views/paintings/new.html.erb b/library/app/views/paintings/new.html.erb
new file mode 100644
index 0000000..f0415bb
--- /dev/null
+++ b/library/app/views/paintings/new.html.erb
@@ -0,0 +1,5 @@
+New Painting
+
+<%= render 'form', painting: @painting %>
+
+<%= link_to 'Back', paintings_path %>
diff --git a/library/app/views/paintings/show.html.erb b/library/app/views/paintings/show.html.erb
new file mode 100644
index 0000000..5907763
--- /dev/null
+++ b/library/app/views/paintings/show.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+
+ Title:
+ <%= @painting.title %>
+
+
+
+ Artist:
+ <%= @painting.artist %>
+
+
+<%= link_to 'Edit', edit_painting_path(@painting) %> |
+<%= link_to 'Back', paintings_path %>
diff --git a/library/app/views/paintings/show.json.jbuilder b/library/app/views/paintings/show.json.jbuilder
new file mode 100644
index 0000000..d06beba
--- /dev/null
+++ b/library/app/views/paintings/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "paintings/painting", painting: @painting
diff --git a/library/config/routes.rb b/library/config/routes.rb
index a935920..b7b5d70 100644
--- a/library/config/routes.rb
+++ b/library/config/routes.rb
@@ -1,23 +1,30 @@
Rails.application.routes.draw do
+ resources :articles do
+ resources :comments
+ end
+ resources :paintings
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- get '/books' => "books#index" , as:'books' #books_path
- get '/books/new' => "books#new" , as: 'new_book'
- get '/books/:id/edit' => "books#edit" , as:'edit_book'
- get '/books/:id' => "books#show" , as: 'book' #book_path(book)
- get '/movies' => "movies#index" , as: 'movies'
- get '/movies/new' => "movies#new" , as: 'new_movie'
- get '/movies/:id/edit' => "movies#edit" , as:'edit_movie'
- get '/movies/:id' => "movies#show" , as: 'movie'
- get '/ingredients' => "ingredients#index" , as: 'ingredients'
- get '/ingredients/:id' => "ingredients#show" , as: 'ingredient'
+ # get '/books' => "books#index" , as:'books' #books_path
+ # get '/books/new' => "books#new" , as: 'new_book'
+ # get '/books/:id/edit' => "books#edit" , as:'edit_book'
+ # get '/books/:id' => "books#show" , as: 'book' #book_path(book)
+ # get '/movies' => "movies#index" , as: 'movies'
+ # get '/movies/new' => "movies#new" , as: 'new_movie'
+ # get '/movies/:id/edit' => "movies#edit" , as:'edit_movie'
+ # get '/movies/:id' => "movies#show" , as: 'movie'
+ # get '/ingredients' => "ingredients#index" , as: 'ingredients'
+ # get '/ingredients/:id' => "ingredients#show" , as: 'ingredient'
- post '/books' => "books#create"
- post '/movies' => "movies#create"
- patch '/books/:id' => "books#update"
- patch '/movies/:id' => "movies#update"
- delete '/books/:id' => "books#destroy"
- delete '/movies/:id' => "movies#destroy"
+ # post '/books' => "books#create"
+ # post '/movies' => "movies#create"
+ # patch '/books/:id' => "books#update"
+ # patch '/movies/:id' => "movies#update"
+ # delete '/books/:id' => "books#destroy"
+ # delete '/movies/:id' => "movies#destroy"
+ resources :books
+ resources :movies
+ resources :ingredients
end
diff --git a/library/db/migrate/20190303122652_create_paintings.rb b/library/db/migrate/20190303122652_create_paintings.rb
new file mode 100644
index 0000000..727b520
--- /dev/null
+++ b/library/db/migrate/20190303122652_create_paintings.rb
@@ -0,0 +1,10 @@
+class CreatePaintings < ActiveRecord::Migration[5.2]
+ def change
+ create_table :paintings do |t|
+ t.string :title
+ t.string :artist
+
+ t.timestamps
+ end
+ end
+end
diff --git a/library/db/migrate/20190303132522_create_articles.rb b/library/db/migrate/20190303132522_create_articles.rb
new file mode 100644
index 0000000..b9c6306
--- /dev/null
+++ b/library/db/migrate/20190303132522_create_articles.rb
@@ -0,0 +1,10 @@
+class CreateArticles < ActiveRecord::Migration[5.2]
+ def change
+ create_table :articles do |t|
+ t.string :title
+ t.string :text
+
+ t.timestamps
+ end
+ end
+end
diff --git a/library/db/migrate/20190303134138_create_comments.rb b/library/db/migrate/20190303134138_create_comments.rb
new file mode 100644
index 0000000..818b13a
--- /dev/null
+++ b/library/db/migrate/20190303134138_create_comments.rb
@@ -0,0 +1,14 @@
+
+class CreateComments < ActiveRecord::Migration[5.0]
+ def change
+ create_table :comments do |t|
+ t.string :commenter
+ t.text :body
+ t.references :article, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
+
+
diff --git a/library/db/schema.rb b/library/db/schema.rb
index cfa93ec..4caf6e9 100644
--- a/library/db/schema.rb
+++ b/library/db/schema.rb
@@ -10,7 +10,14 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2) do
+ActiveRecord::Schema.define(version: 2019_03_03_134138) do
+
+ create_table "articles", force: :cascade do |t|
+ t.string "title"
+ t.string "text"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
create_table "books", force: :cascade do |t|
t.string "title"
@@ -19,6 +26,15 @@
t.datetime "updated_at", null: false
end
+ create_table "comments", force: :cascade do |t|
+ t.string "commenter"
+ t.text "body"
+ t.integer "article_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["article_id"], name: "index_comments_on_article_id"
+ end
+
create_table "ingredients", force: :cascade do |t|
t.string "name"
t.string "unit"
@@ -37,4 +53,11 @@
t.datetime "updated_at", null: false
end
+ create_table "paintings", force: :cascade do |t|
+ t.string "title"
+ t.string "artist"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
end
diff --git a/library/test/controllers/articles_controller_test.rb b/library/test/controllers/articles_controller_test.rb
new file mode 100644
index 0000000..c3c5ba1
--- /dev/null
+++ b/library/test/controllers/articles_controller_test.rb
@@ -0,0 +1,48 @@
+require 'test_helper'
+
+class ArticlesControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @article = articles(:one)
+ end
+
+ test "should get index" do
+ get articles_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_article_url
+ assert_response :success
+ end
+
+ test "should create article" do
+ assert_difference('Article.count') do
+ post articles_url, params: { article: { text: @article.text, title: @article.title } }
+ end
+
+ assert_redirected_to article_url(Article.last)
+ end
+
+ test "should show article" do
+ get article_url(@article)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_article_url(@article)
+ assert_response :success
+ end
+
+ test "should update article" do
+ patch article_url(@article), params: { article: { text: @article.text, title: @article.title } }
+ assert_redirected_to article_url(@article)
+ end
+
+ test "should destroy article" do
+ assert_difference('Article.count', -1) do
+ delete article_url(@article)
+ end
+
+ assert_redirected_to articles_url
+ end
+end
diff --git a/library/test/controllers/comments_controller_test.rb b/library/test/controllers/comments_controller_test.rb
new file mode 100644
index 0000000..a812dda
--- /dev/null
+++ b/library/test/controllers/comments_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/library/test/controllers/paintings_controller_test.rb b/library/test/controllers/paintings_controller_test.rb
new file mode 100644
index 0000000..99dbbc4
--- /dev/null
+++ b/library/test/controllers/paintings_controller_test.rb
@@ -0,0 +1,48 @@
+require 'test_helper'
+
+class PaintingsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @painting = paintings(:one)
+ end
+
+ test "should get index" do
+ get paintings_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_painting_url
+ assert_response :success
+ end
+
+ test "should create painting" do
+ assert_difference('Painting.count') do
+ post paintings_url, params: { painting: { artist: @painting.artist, title: @painting.title } }
+ end
+
+ assert_redirected_to painting_url(Painting.last)
+ end
+
+ test "should show painting" do
+ get painting_url(@painting)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_painting_url(@painting)
+ assert_response :success
+ end
+
+ test "should update painting" do
+ patch painting_url(@painting), params: { painting: { artist: @painting.artist, title: @painting.title } }
+ assert_redirected_to painting_url(@painting)
+ end
+
+ test "should destroy painting" do
+ assert_difference('Painting.count', -1) do
+ delete painting_url(@painting)
+ end
+
+ assert_redirected_to paintings_url
+ end
+end
diff --git a/library/test/fixtures/articles.yml b/library/test/fixtures/articles.yml
new file mode 100644
index 0000000..d644cad
--- /dev/null
+++ b/library/test/fixtures/articles.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ title: MyString
+ text: MyString
+
+two:
+ title: MyString
+ text: MyString
diff --git a/library/test/fixtures/comments.yml b/library/test/fixtures/comments.yml
new file mode 100644
index 0000000..59459ff
--- /dev/null
+++ b/library/test/fixtures/comments.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ commenter: MyString
+ body: MyText
+
+two:
+ commenter: MyString
+ body: MyText
diff --git a/library/test/fixtures/paintings.yml b/library/test/fixtures/paintings.yml
new file mode 100644
index 0000000..e2eeb2d
--- /dev/null
+++ b/library/test/fixtures/paintings.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ title: MyString
+ artist: MyString
+
+two:
+ title: MyString
+ artist: MyString
diff --git a/library/test/models/article_test.rb b/library/test/models/article_test.rb
new file mode 100644
index 0000000..11c8abe
--- /dev/null
+++ b/library/test/models/article_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ArticleTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/library/test/models/comment_test.rb b/library/test/models/comment_test.rb
new file mode 100644
index 0000000..b6d6131
--- /dev/null
+++ b/library/test/models/comment_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/library/test/models/painting_test.rb b/library/test/models/painting_test.rb
new file mode 100644
index 0000000..6f0053e
--- /dev/null
+++ b/library/test/models/painting_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PaintingTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/library/test/system/articles_test.rb b/library/test/system/articles_test.rb
new file mode 100644
index 0000000..80b6085
--- /dev/null
+++ b/library/test/system/articles_test.rb
@@ -0,0 +1,45 @@
+require "application_system_test_case"
+
+class ArticlesTest < ApplicationSystemTestCase
+ setup do
+ @article = articles(:one)
+ end
+
+ test "visiting the index" do
+ visit articles_url
+ assert_selector "h1", text: "Articles"
+ end
+
+ test "creating a Article" do
+ visit articles_url
+ click_on "New Article"
+
+ fill_in "Text", with: @article.text
+ fill_in "Title", with: @article.title
+ click_on "Create Article"
+
+ assert_text "Article was successfully created"
+ click_on "Back"
+ end
+
+ test "updating a Article" do
+ visit articles_url
+ click_on "Edit", match: :first
+
+ fill_in "Text", with: @article.text
+ fill_in "Title", with: @article.title
+ click_on "Update Article"
+
+ assert_text "Article was successfully updated"
+ click_on "Back"
+ end
+
+ test "destroying a Article" do
+ visit articles_url
+ page.accept_confirm do
+ click_on "Destroy", match: :first
+ end
+
+ assert_text "Article was successfully destroyed"
+ end
+end
diff --git a/library/test/system/paintings_test.rb b/library/test/system/paintings_test.rb
new file mode 100644
index 0000000..28fb49d
--- /dev/null
+++ b/library/test/system/paintings_test.rb
@@ -0,0 +1,45 @@
+require "application_system_test_case"
+
+class PaintingsTest < ApplicationSystemTestCase
+ setup do
+ @painting = paintings(:one)
+ end
+
+ test "visiting the index" do
+ visit paintings_url
+ assert_selector "h1", text: "Paintings"
+ end
+
+ test "creating a Painting" do
+ visit paintings_url
+ click_on "New Painting"
+
+ fill_in "Artist", with: @painting.artist
+ fill_in "Title", with: @painting.title
+ click_on "Create Painting"
+
+ assert_text "Painting was successfully created"
+ click_on "Back"
+ end
+
+ test "updating a Painting" do
+ visit paintings_url
+ click_on "Edit", match: :first
+
+ fill_in "Artist", with: @painting.artist
+ fill_in "Title", with: @painting.title
+ click_on "Update Painting"
+
+ assert_text "Painting was successfully updated"
+ click_on "Back"
+ end
+
+ test "destroying a Painting" do
+ visit paintings_url
+ page.accept_confirm do
+ click_on "Destroy", match: :first
+ end
+
+ assert_text "Painting was successfully destroyed"
+ end
+end
From 7acce6b9bb8f76e58c4a4409df8c1ebe72539fcb Mon Sep 17 00:00:00 2001
From: ceahmad
Date: Mon, 4 Mar 2019 10:20:16 +0300
Subject: [PATCH 3/3] Cmmpleted all
---
.../app/controllers/articles_controller.rb | 1 +
.../app/controllers/comments_controller.rb | 28 ++++++++------
library/app/models/article.rb | 4 +-
library/app/views/articles/show.html.erb | 37 ++++++-------------
library/app/views/comments/_comment.html.erb | 16 ++++++++
library/app/views/comments/_form.html.erb | 13 +++++++
library/app/views/comments/show.html.erb | 20 ++++++++++
7 files changed, 81 insertions(+), 38 deletions(-)
create mode 100644 library/app/views/comments/_comment.html.erb
create mode 100644 library/app/views/comments/_form.html.erb
create mode 100644 library/app/views/comments/show.html.erb
diff --git a/library/app/controllers/articles_controller.rb b/library/app/controllers/articles_controller.rb
index 4536962..2fe1ad6 100644
--- a/library/app/controllers/articles_controller.rb
+++ b/library/app/controllers/articles_controller.rb
@@ -72,3 +72,4 @@ def article_params
params.require(:article).permit(:title, :text)
end
end
+
diff --git a/library/app/controllers/comments_controller.rb b/library/app/controllers/comments_controller.rb
index c4e33de..df7bee8 100644
--- a/library/app/controllers/comments_controller.rb
+++ b/library/app/controllers/comments_controller.rb
@@ -1,13 +1,19 @@
-
class CommentsController < ApplicationController
- def create
- @article = Article.find(params[:article_id])
- @comment = @article.comments.create(comment_params)
- redirect_to article_path(@article)
+ def create
+ @article = Article.find(params[:article_id])
+ @comment = @article.comments.create(comment_params)
+ redirect_to article_path(@article)
+ end
+
+ def destroy
+ @article = Article.find(params[:article_id])
+ @comment = @article.comments.find(params[:id])
+ @comment.destroy
+ redirect_to article_path(@article)
+ end
+
+ private
+ def comment_params
+ params.require(:comment).permit(:commenter, :body)
end
-
- private
- def comment_params
- params.require(:comment).permit(:commenter, :body)
- end
- end
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/library/app/models/article.rb b/library/app/models/article.rb
index dcbf935..90bd1d3 100644
--- a/library/app/models/article.rb
+++ b/library/app/models/article.rb
@@ -1,6 +1,6 @@
-class Article < ApplicationRecord
- has_many :comments
+ class Article < ApplicationRecord
+ has_many :comments, dependent: :destroy
validates :title, presence: true,
length: { minimum: 5 }
end
\ No newline at end of file
diff --git a/library/app/views/articles/show.html.erb b/library/app/views/articles/show.html.erb
index 54c1ff7..ef60e82 100644
--- a/library/app/views/articles/show.html.erb
+++ b/library/app/views/articles/show.html.erb
@@ -1,31 +1,18 @@
-
-Comments
-<% @article.comments.each do |comment| %>
-
- Commenter:
- <%= comment.commenter %>
-
+
+ Title:
+ <%= @article.title %>
+
+
+
+ Text:
+ <%= @article.text %>
+
-
- Comment:
- <%= comment.body %>
-
-<% end %>
+Comments
+<%= render @article.comments %>
Add a comment:
-<%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %>
-
- <%= form.label :commenter %>
- <%= form.text_field :commenter %>
-
-
- <%= form.label :body %>
- <%= form.text_area :body %>
-
-
- <%= form.submit %>
-
-<% end %>
+<%= render 'comments/form' %>
<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
diff --git a/library/app/views/comments/_comment.html.erb b/library/app/views/comments/_comment.html.erb
new file mode 100644
index 0000000..4d1e3a8
--- /dev/null
+++ b/library/app/views/comments/_comment.html.erb
@@ -0,0 +1,16 @@
+
+
+Commenter:
+<%= comment.commenter %>
+
+
+
+Comment:
+<%= comment.body %>
+
+
+
+<%= link_to 'Destroy Comment', [comment.article, comment],
+ method: :delete,
+ data: { confirm: 'Are you sure?' } %>
+
\ No newline at end of file
diff --git a/library/app/views/comments/_form.html.erb b/library/app/views/comments/_form.html.erb
new file mode 100644
index 0000000..1af7768
--- /dev/null
+++ b/library/app/views/comments/_form.html.erb
@@ -0,0 +1,13 @@
+<%= form_with(model: [ @article, @article.comments.build ], local: true) do |form| %>
+
+ <%= form.label :commenter %>
+ <%= form.text_field :commenter %>
+
+
+ <%= form.label :body %>
+ <%= form.text_area :body %>
+
+
+ <%= form.submit %>
+
+ <% end %>
\ No newline at end of file
diff --git a/library/app/views/comments/show.html.erb b/library/app/views/comments/show.html.erb
new file mode 100644
index 0000000..893d6eb
--- /dev/null
+++ b/library/app/views/comments/show.html.erb
@@ -0,0 +1,20 @@
+
+
+
+Title:
+<%= @article.title %>
+
+
+
+Text:
+<%= @article.text %>
+
+
+Comments
+<%= render @article.comments %>
+
+Add a comment:
+<%= render 'comments/form' %>
+
+<%= link_to 'Edit', edit_article_path(@article) %> |
+<%= link_to 'Back', articles_path %>