diff --git a/.gitpod.yml b/.gitpod.yml index bb8d3e4..9deaa84 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,13 +1,25 @@ -image: jelaniwoods/appdev2023-helper-methods +image: jelaniwoods/appdev2023-rails-template tasks: - before: | + sudo cp -r /home/student /home/gitpod + (cd /home/gitpod/student; sudo find . -maxdepth 1 -exec mv {} .. \;) + source ~/.bashrc + sudo chmod 777 /home/gitpod && sudo chown -R gitpod /home/gitpod /home/student + export GEM_HOME=/workspace/.rvm + export GEM_PATH=$GEM_HOME:$GEM_PATH + export PATH=/workspace/.rvm/bin:$PATH bin/setup - .vscode/manage_extensions ports: - port: 3000 onOpen: open-preview visibility: public + - port: 4567 + onOpen: open-preview + visibility: public + - port: 9292 + onOpen: open-preview + visibility: public - port: 5432 onOpen: ignore @@ -16,3 +28,5 @@ vscode: - vortizhe.simple-ruby-erb - mbessey.vscode-rufo - aliariff.vscode-erb-beautify + - eamodio.gitlens + - setobiralo.erb-commenter diff --git a/.vscode/settings.json b/.vscode/settings.json index c61c9cc..a31597e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,6 +40,7 @@ "[ruby]": { "editor.formatOnSave": true }, + "terminal.integrated.defaultProfile.linux": "bash", "vscode-erb-beautify.keepBlankLines": 1, "vscode-erb-beautify.bundlerPath": "/home/gitpod/.rvm/ruby-3.0.3/bin/bundler", "vscode-erb-beautify.useBundler": true, diff --git a/Gemfile.lock b/Gemfile.lock index ad51965..61eaa3e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/firstdraft/web_git.git - revision: 614ba241422a5516f5a0a02ff75557640e87a855 + revision: d1d7d2d70cb66ec233229e53f2ec578df0c585b0 specs: web_git (0.1.0) actionview @@ -13,66 +13,66 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7) - actionpack (= 6.1.7) - activesupport (= 6.1.7) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7) - actionpack (= 6.1.7) - activejob (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + actionmailbox (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (>= 2.7.1) - actionmailer (6.1.7) - actionpack (= 6.1.7) - actionview (= 6.1.7) - activejob (= 6.1.7) - activesupport (= 6.1.7) + actionmailer (6.1.7.6) + actionpack (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7) - actionview (= 6.1.7) - activesupport (= 6.1.7) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7) - actionpack (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + actiontext (6.1.7.6) + actionpack (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) nokogiri (>= 1.8.5) - actionview (6.1.7) - activesupport (= 6.1.7) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7) - activesupport (= 6.1.7) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (6.1.7) - activesupport (= 6.1.7) - activerecord (6.1.7) - activemodel (= 6.1.7) - activesupport (= 6.1.7) - activestorage (6.1.7) - actionpack (= 6.1.7) - activejob (= 6.1.7) - activerecord (= 6.1.7) - activesupport (= 6.1.7) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + activestorage (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activesupport (= 6.1.7.6) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) @@ -81,7 +81,7 @@ GEM ast (2.4.2) awesome_print (1.9.2) backport (1.2.0) - benchmark (0.2.0) + benchmark (0.2.1) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) @@ -92,7 +92,7 @@ GEM bootsnap (1.13.0) msgpack (~> 1.2) builder (3.2.4) - bullet (7.0.3) + bullet (7.0.7) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) @@ -123,16 +123,16 @@ GEM git (1.12.0) addressable (~> 2.8) rchardet (~> 1.8) - globalid (1.0.0) + globalid (1.0.1) activesupport (>= 5.0) htmlbeautifier (1.4.2) i18n (1.12.0) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.4) + jaro_winkler (1.5.6) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.6.2) + json (2.6.3) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) @@ -140,7 +140,7 @@ GEM listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.19.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -148,57 +148,55 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.8.0) + mini_mime (1.1.5) + mini_portile2 (2.8.5) minitest (5.16.3) - msgpack (1.6.0) + msgpack (1.6.1) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - nio4r (2.5.8) - nokogiri (1.13.9) + nio4r (2.5.9) + nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.9-x86_64-darwin) - racc (~> 1.4) parallel (1.22.1) - parser (3.1.2.1) + parser (3.1.3.0) ast (~> 2.4.1) - pg (1.4.4) - pry (0.14.1) + pg (1.4.6) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (5.0.0) - puma (5.6.5) + public_suffix (5.0.4) + puma (5.6.7) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) + racc (1.6.2) + rack (2.2.8) rack-canonical-host (1.1.0) addressable (> 0, < 3) rack (>= 1.0.0, < 3) rack-mini-profiler (2.3.4) rack (>= 1.2.0) - rack-protection (3.0.3) + rack-protection (3.0.6) rack - rack-proxy (0.7.4) + rack-proxy (0.7.7) rack rack-test (2.0.2) rack (>= 1.3) - rails (6.1.7) - actioncable (= 6.1.7) - actionmailbox (= 6.1.7) - actionmailer (= 6.1.7) - actionpack (= 6.1.7) - actiontext (= 6.1.7) - actionview (= 6.1.7) - activejob (= 6.1.7) - activemodel (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + rails (6.1.7.6) + actioncable (= 6.1.7.6) + actionmailbox (= 6.1.7.6) + actionmailer (= 6.1.7.6) + actionpack (= 6.1.7.6) + actiontext (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activemodel (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) bundler (>= 1.15.0) - railties (= 6.1.7) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -208,11 +206,11 @@ GEM activesupport (>= 4.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - railties (6.1.7) - actionpack (= 6.1.7) - activesupport (= 6.1.7) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source rake (>= 12.2) thor (~> 1.0) @@ -222,11 +220,11 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rchardet (1.8.0) - regexp_parser (2.6.0) + regexp_parser (2.6.2) reverse_markdown (2.1.1) nokogiri - rexml (3.2.5) - rollbar (3.3.2) + rexml (3.2.6) + rollbar (3.3.3) rubocop (1.39.0) json (~> 2.3) parallel (~> 1.10) @@ -239,10 +237,10 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-performance (1.15.0) + rubocop-performance (1.15.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.17.2) + rubocop-rails (2.17.4) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -270,10 +268,10 @@ GEM rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) semantic_range (3.0.0) - sinatra (3.0.3) + sinatra (3.0.6) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.3) + rack-protection (= 3.0.6) tilt (~> 2.0) skylight (5.3.4) activesupport (>= 5.2.0) @@ -292,7 +290,7 @@ GEM thor (~> 1.0) tilt (~> 2.0) yard (~> 0.9, >= 0.9.24) - spring (4.1.0) + spring (4.1.2) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -300,21 +298,21 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - standard (1.18.0) + standard (1.18.1) rubocop (= 1.39.0) - rubocop-performance (= 1.15.0) - thor (1.2.1) + rubocop-performance (= 1.15.1) + thor (1.2.2) tilt (2.0.11) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2022.6) + tzinfo-data (1.2022.7) tzinfo (>= 1.0.0) unicode-display_width (2.3.0) uniform_notifier (1.16.0) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) @@ -323,21 +321,19 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) - webpacker (5.4.3) + webpacker (5.4.4) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - webrick (1.7.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.28) - webrick (~> 1.7.0) - zeitwerk (2.6.6) + yard (0.9.34) + zeitwerk (2.6.12) PLATFORMS ruby diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 13820e3..d98d7fd 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,4 +1,6 @@ class MoviesController < ApplicationController + before_action :set_movie, only: [:show, :edit, :update, :destroy] + def new @movie = Movie.new end @@ -14,12 +16,9 @@ def index end def show - @movie = Movie.find(params.fetch(:id)) end def create - movie_params = params.require(:movie).permit(:title, :description) - @movie = Movie.new(movie_params) if @movie.valid? @@ -32,14 +31,9 @@ def create end def edit - @movie = Movie.find(params.fetch(:id)) end def update - @movie = Movie.find(params.fetch(:id)) - - movie_params = params.require(:movie).permit(:title, :description) - if @movie.update(movie_params) redirect_to @movie, notice: "Movie updated successfully." else @@ -48,10 +42,18 @@ def update end def destroy - @movie = Movie.find(params.fetch(:id)) - @movie.destroy redirect_to movies_url, notice: "Movie deleted successfully." end + + private + + def movie_params + movie_params = params.require(:movie).permit(:title, :description) + end + + def set_movie + @movie = Movie.find(params.fetch(:id)) + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4d58400..85bced9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,24 +1,28 @@
-<%= message %>
<% end %> -<%= form_with model: @movie do |form| %> -| - ID - | - -- Title - | - -- Description - | - -- Created at - | - -- Updated at - | - -- | -
|---|---|---|---|---|---|
| - <%= movie.id %> - | - -- <%= movie.title %> - | - -- <%= movie.description %> - | - -- <%= time_ago_in_words(movie.created_at) %> ago - | -- <%= time_ago_in_words(movie.updated_at) %> ago - | - -- <%= link_to "Show details", movie %> - | -
<%= message %>
<% end %> -<%= form_with model: @movie do |form| %> -