From 3135ee3bf796cd59526e055a43b8ca1bb3d73012 Mon Sep 17 00:00:00 2001 From: Leah Scott-Zechlin Date: Wed, 20 Jan 2021 15:36:25 -0800 Subject: [PATCH 1/2] pseudocode add video to db --- .generators | 8 +++++++ .gitignore | 1 + app/controllers/videos_controller.rb | 32 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 .generators diff --git a/.generators b/.generators new file mode 100644 index 00000000..16189766 --- /dev/null +++ b/.generators @@ -0,0 +1,8 @@ + + diff --git a/.gitignore b/.gitignore index cb5b9b3e..d2b370fe 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ # Ignore Byebug command history file. .byebug_history .env +.idea # Ignore master key for decrypting credentials and more. /config/master.key diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb index c9a2bb08..202ce164 100644 --- a/app/controllers/videos_controller.rb +++ b/app/controllers/videos_controller.rb @@ -1,4 +1,6 @@ class VideosController < ApplicationController + require 'httparty' + before_action :require_video, only: [:show] def index @@ -21,6 +23,36 @@ def show ) end + # ANSEL ADVICE + # Make use of video wrapper code to make call to TMDB + # Get it from rails application. + # In React user enters title and inventory. + # This talks to Rails via the axios + # Rails code then queries tmdb to get details for that movie + # Then add it into your database + # Router is just to selectively show or hide bits of the React app + # It amkes it look like there are different routes to visit, but there really aren't bc single page app + # web server that react runs is special bc requests sent into it get sent to react app running, regardless of path in address bar, anything coming in gets sent to index.js + # + # + # Is it get or post? Get from tmdb + + + # look up the title to get data + # add to db + # doesnt sound like enough to make a helperclass + # put it in an action in controller + # just make use of wrapper + + def add_new_video.get(url, params) + SEE VIDEO WRAPPER + URL = "the url of tmdb --search the video" + response = HTTParty.get(url, query: params) + + we format the response to have the info we want to add to the video table + then we .save to the video table + end + private def require_video From d45d79ffe271c9c1f01ea41cde6be9d065e6c38d Mon Sep 17 00:00:00 2001 From: Leah Scott-Zechlin Date: Wed, 20 Jan 2021 21:29:40 -0800 Subject: [PATCH 2/2] commented out video controller notes --- app/controllers/videos_controller.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb index 202ce164..6decde1e 100644 --- a/app/controllers/videos_controller.rb +++ b/app/controllers/videos_controller.rb @@ -44,14 +44,14 @@ def show # put it in an action in controller # just make use of wrapper - def add_new_video.get(url, params) - SEE VIDEO WRAPPER - URL = "the url of tmdb --search the video" - response = HTTParty.get(url, query: params) - - we format the response to have the info we want to add to the video table - then we .save to the video table - end + # def add_new_video.get(url, params) + # SEE VIDEO WRAPPER + # URL = "the url of tmdb --search the video" + # response = HTTParty.get(url, query: params) + # + # we format the response to have the info we want to add to the video table + # then we .save to the video table + # end private