<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: K Montgomery</title>
    <description>The latest articles on DEV Community by K Montgomery (@montgomeryk1).</description>
    <link>https://dev.to/montgomeryk1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F841900%2F5d038490-ba6f-4887-a391-357b8414966c.png</url>
      <title>DEV Community: K Montgomery</title>
      <link>https://dev.to/montgomeryk1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/montgomeryk1"/>
    <language>en</language>
    <item>
      <title>Delete and Destroy</title>
      <dc:creator>K Montgomery</dc:creator>
      <pubDate>Thu, 14 Jul 2022 17:57:39 +0000</pubDate>
      <link>https://dev.to/montgomeryk1/delete-and-destroy-2k06</link>
      <guid>https://dev.to/montgomeryk1/delete-and-destroy-2k06</guid>
      <description>&lt;p&gt;The simplest breakdown: destroy runs any callbacks and delete doesn't. What all does that mean though? Why are there two different functions? When do you implement them? How do you know when to implement the different functions?  Does it really matter??&lt;/p&gt;

&lt;p&gt;Well. The answer to all of those questions is incredibly nuanced once you really get into it. But the answer to the most important one of "does it matter?" is Yes. It really does. Lets start with delete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does delete do?&lt;/strong&gt;&lt;br&gt;
In the most basic terms I can possibly write, delete just removes the selected SQL row and then returns the number of rows deleted. There is no behind the scenes. You just remove the data from the database. &lt;/p&gt;

&lt;p&gt;Now... &lt;strong&gt;What does destroy do?&lt;/strong&gt;&lt;br&gt;
Destroy, on top of removing the selected SQL row fires off all of the callbacks and filters before the object(s) is deleted and it also removes the specific ID(s) from the table. It essentially creates a new object from the attributes and then calls destroy on it.&lt;/p&gt;

&lt;p&gt;While destroy is less efficient than delete &lt;em&gt;because&lt;/em&gt; it fires off callbacks and filters, such things are necessary in certain instances because all of those methods being called allows for cleanup methods to work their magic. &lt;/p&gt;

&lt;p&gt;Even though it seems like it it would make more sense to use destroy all the time, you can and should use delete if you want your object to be removed more quickly buuuut, you should absolutely use destroy if you care about your validations and your callbacks. It might run slower but it will make things easier for you in the long run. Like everything with code use common sense and ask questions! There is no one right answer to anything!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Getting railed by ruby</title>
      <dc:creator>K Montgomery</dc:creator>
      <pubDate>Mon, 27 Jun 2022 14:51:37 +0000</pubDate>
      <link>https://dev.to/montgomeryk1/getting-railed-by-ruby-2bll</link>
      <guid>https://dev.to/montgomeryk1/getting-railed-by-ruby-2bll</guid>
      <description>&lt;p&gt;Finally made it through my ruby and ruby on rails curriculum and I have a lot of thoughts on the backend framework. First and foremost: writing out CRUD is so incredibly quick and easy. Just a simple&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    def create
        user = User.create!(user_params)
        render json: user, status: :created
    end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(with different variables and params, obviously) will get you a super quick way to write out a way to store new data as you continue through your project. I began learning coding in Java and JavaScript like most devs and I always wondered why certain actions were so convoluted and I just wanted to start learning ruby/ruby on rails to see if programming would always lead me to want to put my head through a monitor. While each and every language and framework has its own benefits and setbacks I personally feel like ruby reads a lot more modern AND does a lot of work for you. Which personally, the less I have to type the better.&lt;/p&gt;

&lt;p&gt;All in all, Ruby and Ruby on rails is such a lightweight framework that pulls heavy weight work in a way that is incredibly easy to understand, build out, and manipulate into exactly what you want done. Along with super easy integration with JavaScript, Ruby and rails helps make complex websites that run quickly and smoothly.&lt;/p&gt;

&lt;p&gt;One of the main benefits I've noticed about Ruby as a whole is absolutely the fact that when you have an error, it'll freak out on you and tell you exactly where things went wrong and HOW to fix it. Makes debugging and finding that stray comma a thousand times easier.&lt;/p&gt;

&lt;p&gt;All in all every language and framework has their own benefits and drawbacks and I really feel like I have only started chipping away at the tip of the iceberg in really understanding what I as a newer developer can do.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>ruby</category>
      <category>rails</category>
    </item>
    <item>
      <title>Embedded videos with react but make it easy.</title>
      <dc:creator>K Montgomery</dc:creator>
      <pubDate>Fri, 13 May 2022 18:00:33 +0000</pubDate>
      <link>https://dev.to/montgomeryk1/embedded-videos-with-react-but-make-it-easy-2123</link>
      <guid>https://dev.to/montgomeryk1/embedded-videos-with-react-but-make-it-easy-2123</guid>
      <description>&lt;p&gt;For my react based project for school, I decided to go way in over my head with routing, embeds, and functionality considering I only had about 3 days to finish it... but one of the big features I wanted to include was creating a route to a page with an embedded YouTube video playing a trailer for the specific documentary that was selected on the home screen. Now how did we accomplish this?&lt;/p&gt;

&lt;p&gt;For starters: Routing. We created our routes, and instead of placing the route to the page with all of the trailers on one page we passed the links to the trailers down through a props and tagged the route on the images with a link tag.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Link to={&lt;/code&gt;/youtube/${embedId}&lt;code&gt;}&amp;gt;&lt;br&gt;
        &amp;lt;img src={docInfo.image} alt={docInfo.comment} /&amp;gt;&lt;br&gt;
        &amp;lt;/Link&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And the rest of the routing inside of your App.js component...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;return (&lt;br&gt;
    &amp;lt;&amp;gt;&lt;br&gt;
    &amp;lt;Header search={search} handleSearch={handleSearch} /&amp;gt;&lt;br&gt;
    &amp;lt;Switch&amp;gt;&lt;br&gt;
    &amp;lt;div className="app"&amp;gt;&lt;br&gt;
    &amp;lt;Route path='/newdocform'&amp;gt;&lt;br&gt;
      &amp;lt;NewDocForm addNewDoc={addNewDoc}/&amp;gt;&lt;br&gt;
    &amp;lt;/Route&amp;gt;&lt;br&gt;
      &amp;lt;Route exact path="/"&amp;gt;&lt;br&gt;
      &amp;lt;DocuContainer&lt;br&gt;
        natureDocs={displayedListings}&lt;br&gt;
      /&amp;gt;&lt;br&gt;
      &amp;lt;/Route&amp;gt;&lt;br&gt;
      &amp;lt;Route  path='/youtube/:embedId'&amp;gt; &lt;br&gt;
      &amp;lt;Trailer /&amp;gt;&lt;br&gt;
      &amp;lt;/Route&amp;gt;&lt;br&gt;
    &amp;lt;/div&amp;gt;&lt;br&gt;
    &amp;lt;/Switch&amp;gt;&lt;br&gt;
    &amp;lt;/&amp;gt;&lt;br&gt;
  );&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once you have you route tagged on to the image and have built out the rest of your routing you should be able to route through your webpage by clicking your images!!&lt;/p&gt;

&lt;p&gt;Now here comes the easiest part: embedding videos.&lt;/p&gt;

&lt;p&gt;Embedding is was easier than you think. For one, YouTube specifically has an embed option for using their videos with all the code you need for example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;iframe &lt;br&gt;
width="560" &lt;br&gt;
height="315" src="https://www.youtube.com/embed/QjVLMU9MdOY"&lt;br&gt;
title="YouTube video player" &lt;br&gt;
frameborder="0" &lt;br&gt;
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&amp;gt;&lt;br&gt;
&amp;lt;/iframe&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The type of tag that you need to make everything function properly is an . iframes work by creating a space within your site that allows a separate document to be displayed within your webpage without needing to redirect. You can also make iframes dynamic.&lt;/p&gt;

&lt;p&gt;For my project, we decided to dynamically render the videos within the routing so we changed our SRC from&lt;/p&gt;

&lt;p&gt;&lt;code&gt;src="https://www.youtube.com/embed/QjVLMU9MdOY"&lt;/code&gt;&lt;br&gt;
(this link is just to the Monterey Bay Aquarium jellyfish tank)&lt;/p&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;p&gt;&lt;code&gt;src={"https://www.youtube.com/embed/${embedId}"}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The reason we did that was because when you click the image and you are routed to the page that contains your trailer, we don't want every single trailer to render and we also didn't want only one trailer to render. All together it makes the routing more dynamic and more flexible and also it allows you to pull more complex APIs and include more information in to your webpages. It can help level up your code and it also makes it easier to embed things instead of having to recode out everything to include more complex coding structures. Might as well include things the easy way!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>"Comments are useless and your should not use them" I Strongly Disagree</title>
      <dc:creator>K Montgomery</dc:creator>
      <pubDate>Fri, 22 Apr 2022 13:21:18 +0000</pubDate>
      <link>https://dev.to/montgomeryk1/comments-are-useless-and-your-should-not-use-them-i-strongly-disagree-5a93</link>
      <guid>https://dev.to/montgomeryk1/comments-are-useless-and-your-should-not-use-them-i-strongly-disagree-5a93</guid>
      <description>&lt;p&gt;As a beginner developer. Sometimes it can be extremely difficult to find your way through your code. You know what you're doing but you don't know how you got there or where you're going. Trust me I have the same problem. My instructor has been blessing us with encouragement to not only write comments... but to write a TON of them. Comments are such a useful tool when you're first getting started so you can write yourself steps out piece by piece before you even lay out your code so you can really go through the motions of understanding deliverables.&lt;/p&gt;

&lt;p&gt;I've only been programming for a few weeks now and when I first started I never used to write comments because I feared my code looked messy but in reality... It helped my code look cleaner and more professional in the long run because I knew where to start and where to go. The best part is... is at the end of the day. I doesn't matter how "messy" the code looks while you're writing it as long as the final product looks nice! I don't know why so early on I was stressed about having my code look perfectly clean cut and professional level. But I'm glad I've gotten over that hump in my learning. &lt;/p&gt;

&lt;p&gt;Comments have truly been a life saver for me in writing my own code but I think they should be implemented in every collaborative project to ever grace the internet because without them you can get lost in one another's code when merging files towards the end of the project. Having a list anyone can see of what you were doing and where things are supposed to go can make things so much smoother and at the end of the day the comments don't effect your code beyond line by line aesthetics and code will still run even if it's ugly.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>JavaScript Is Not a Dog. Controlling Fetch is Vital to functionality.</title>
      <dc:creator>K Montgomery</dc:creator>
      <pubDate>Thu, 21 Apr 2022 22:55:50 +0000</pubDate>
      <link>https://dev.to/montgomeryk1/javascript-is-not-a-dog-controlling-fetch-is-vital-to-functionality-2044</link>
      <guid>https://dev.to/montgomeryk1/javascript-is-not-a-dog-controlling-fetch-is-vital-to-functionality-2044</guid>
      <description>&lt;p&gt;Controlling fetch is often something that we as beginner devs don't even realize we need to do. When I first began learning about fetch we were just told it's a function and initially, myself and some cohort-mates assumed you could call it anywhere and without any context... to which we quicky learned that calling fetch all willy-nilly is not only a bad idea but can also cause you to lose control of your fetched API's.&lt;/p&gt;

&lt;p&gt;What do I mean by this? If you make a fetch request inside of another function, you will be able to attach it to variables and call it back later on in your code instead of just having the API data floating around with no where to go.&lt;/p&gt;

&lt;p&gt;I, unfortunately, learned this lesson the hard way. The first time experiencing a code challenge in school I panicked and forgot to nest my fetch request and ended up in tears over being unable to call the data. Don't be like me. A really good method I have found for embedding your fetch call in order to make it more accessible it is:&lt;br&gt;
&lt;code&gt;document.addEventListener('DOMContentLoaded', () =&amp;gt; {&lt;br&gt;
    fetch('http://localhost:3000/')&lt;br&gt;
      .then(resp =&amp;gt; resp.json())&lt;br&gt;
      .then(data =&amp;gt; renderAll(data))&lt;br&gt;
  });&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now what does this function do?&lt;/p&gt;

&lt;p&gt;Line 1: the jest of it is that it is setting up for the data to be called and immediately rendered in to the DOM.&lt;/p&gt;

&lt;p&gt;Line 2: this is the actual fetch command. You use an API URL and pull the data within it in to your terminal&lt;/p&gt;

&lt;p&gt;Line 3: creating the response in .json and activating that command with the ()&lt;/p&gt;

&lt;p&gt;Line 4: I just used generic variables in this example, however, whatever you use in place of "data" and "renderAll" can and SHOULD BE called again in order to access the internal data and have it appear in your webpage. &lt;/p&gt;

&lt;p&gt;You cannot do any of these without the other. They live in blissful harmony together to make your life easier. Trust me on this one. Coding is so full of tears there's no point in making it harder than it needs to be.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
