<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marcos Martinez on Medium]]></title>
        <description><![CDATA[Stories by Marcos Martinez on Medium]]></description>
        <link>https://medium.com/@mmtz2108?source=rss-f05ac15eb117------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_5LgekWWwQYucnsw</url>
            <title>Stories by Marcos Martinez on Medium</title>
            <link>https://medium.com/@mmtz2108?source=rss-f05ac15eb117------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 03:35:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mmtz2108/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Let Rails Work For You]]></title>
            <link>https://medium.com/@mmtz2108/let-rails-work-for-you-b815f6e8c192?source=rss-f05ac15eb117------2</link>
            <guid isPermaLink="false">https://medium.com/p/b815f6e8c192</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Marcos Martinez]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 17:31:17 GMT</pubDate>
            <atom:updated>2022-06-23T17:31:17.745Z</atom:updated>
            <content:encoded><![CDATA[<p>As I sit down to write this, it is nearing the end of phase 4 of my coding bootcamp and I always struggle with topics for blogs. Usually, I like to focus on some trouble points or road blocks I hit during the phase I was in but I did not hit much of one in phase 4. It made sense and one of my fellow students pointed that out to me. Why don’t I just write about that? Write about how Rails does so much work for you with a few simple commands. You just have to be very specific and diligent with how you use these commands.</p><p>Let’s start with one of the basics and probably the most powerful when you are building the backend of your app if you’re using Rails: rails generate resource. If you are unfamiliar with rails generate well then I am so happy you found this blog. This command will build almost whatever you want it to for you. Model? Just use the command rails g (short for generate) model and then spell out which attributes you would like included in your model and its associated table.</p><p>Want to build out a serializer? Controllers?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*Ct060ine6u7sKX3gOMK5KQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*BBd17TpWil9mYqKEgZa3MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*DH-0zQghDRjXjpvGxuT38A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*AxzK5P_-zaA0kCihG4Z3Gw.png" /></figure><p>As we can see, the controller command made us our Greetings controller which in turn also made us our hello method. We just have to write the code within it! Our serializer command made our serializer and generated its declared attributes. Unless you tell it other wise, your attributes will be defined as strings.</p><p>But now we have the tedious task of building our routes in our config file, creating our routes, etc. Isn’t there a better and more powerful way to make these? Yes, there is. As I mentioned earlier, we have rails generate resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*M3AoClQJgeJc1i0xOrKx6A.png" /></figure><p>What this will do is build our model, controller, serializer, and any attributes along with any associations if we define them in the attributes. It will also define all of your CRUD routes in your config file. The no test framework will leave out any unnecessary test files you might not need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*OwJCPp1Em_C08178y5YjvA.png" /></figure><p>In the image above, I used three different resource commands for User, Post, and Comment. Notice, I included an only: to specify each controller method and leave out any unnecessary ones. Otherwise it will prepare all five CRUD routes for you. This one simple and powerful command takes care of much of your backend app set up that you otherwise might spend precious time on. This is what Rails was designed to do, to take care of these tedious bits of code so we as programmers can focus on the harder and more abstract parts.</p><p>Rails is full of these: rescue_from, before_action, etc. These were designed to keep your code DRY (Don’t Repeat Yourself) and to help you free up mental space.</p><p>Additionally, here is a link to to the<a href="https://guides.rubyonrails.org/command_line.html"> Rails 7.0 Command Line Docs</a>. Rails documentation is extensive and well written. I cannot stress enough how much it has helped me out. I hope this brief blog could do the same for you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b815f6e8c192" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Record with Ruby]]></title>
            <link>https://medium.com/@mmtz2108/active-record-with-ruby-d639e34dc4ca?source=rss-f05ac15eb117------2</link>
            <guid isPermaLink="false">https://medium.com/p/d639e34dc4ca</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[activerecord]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Marcos Martinez]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 03:56:18 GMT</pubDate>
            <atom:updated>2022-06-06T03:56:18.381Z</atom:updated>
            <content:encoded><![CDATA[<p>Ah, Ruby! You have been one sneaky opponent and my greatest challenge since starting coding bootcamp. The amount of information we were required to take in was absurd. But all was made well once we were introduced to ActiveRecord Macros. No longer did we have to create our attr_readers, writers, and accessors or determine what situation to call them in. But what exactly is ActiveRecord?</p><p>As the <a href="https://guides.rubyonrails.org/active_record_basics.html">Ruby on Rails guide</a> states, “ Active Record is <strong>the M in MVC — the model — which is the layer of the system responsible for representing business data and logic</strong>. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database.”</p><p>Simple enough, but what exactly does that mean? ActiveRecord allows us to “connect” our data and tables, utilizing one-to-many and many-to-many relationships.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*0TngGtbJqPXWWAuDzpFwOQ.png" /></figure><p>Here is an example of a many-to-many relationship. We have a user that has reviewed many video games. As a result, the user has many video games as well through those reviews. Here are the rest of those models with their ActiveRecord macros:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*o_7bW5J07Sq_jmvY7hQ_tA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*zq-MuwFwmR_Ys6DiAKtSOw.png" /></figure><p>A review belongs to both our game and user models. It becomes the “joiner” table, join model, or middle man. It joins the users and games. Our User and Game models can access each other’s information <em>through</em> our reviews table.</p><p>A user has many reviews and a game has many reviews. Reviews belong to both. Once all three are connected, using our has_many and belongs_to macros, we are able to create other methods to manipulate all of our data as needed. Another way of looking at it is through the models: Doctors, Patients, and Appointments. Doctors have many patients just as patients can have many doctors depending on their ailments. What joins the two are appointments which belongs to both doctors and patients.</p><p>Once you are able to understand this, you’re able to harness the power of ActiveRecord. It does a lot of the heavy lifting for you so you can shorten and optimize your code. As I said earlier, you no longer need to write those attr_readers, writers, and accessors unless you specifically need them for certain situations.</p><p>And that’s all there is to it! Once you set up your macros then you can write your own specialized methods to retrieve, manipulate, and delete the data you need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d639e34dc4ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Props On Your Destructuring, Dude!]]></title>
            <link>https://medium.com/@mmtz2108/props-on-your-destructuring-dude-2fc8386dabf9?source=rss-f05ac15eb117------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fc8386dabf9</guid>
            <category><![CDATA[codingbootcamp]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Marcos Martinez]]></dc:creator>
            <pubDate>Sun, 15 May 2022 03:33:19 GMT</pubDate>
            <atom:updated>2022-05-15T03:33:19.072Z</atom:updated>
            <content:encoded><![CDATA[<p>For the life of me, I do not know why I struggled for so long trying to learn how to use props in React. Passing down props? What does that even mean? What can you pass down? Why can you call props something other than props? Why wouldn’t we just keep props destructured? These are just some of the questions I was asking myself so walk with me, reader, on my brief journey to understanding props and destructuring it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*yg8A6NRvbmuldzcGb8pMAg.png" /></figure><p>See this? This example makes no sense to me. I am very much a hands on learner so learning concepts from audio or visual recordings is tough for me. But my immediate frustration here, now knowing what props is, is the syntax here. The overwhelming majority of the time you are going to put your props in curly braces as demonstrated on lines 2 of this code. The other thing is the name never makes sense to me.</p><p>It wasn’t until it was explained to me that props are like packages that we send to our child components to get them to be able to function well. Like sending a care package to someone you care about. Inside of that care package you can have a function, variables, attributes, whatever. The thing that you have to understand is that props is meant to help us pass functionality in our app. It’s all working together, it’s bonded. Understanding how the component hierarchy works together was absolutely crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*YIV8uy1fio-n6g8TRdMVDw.png" /></figure><p>The components to pay attention to here are App, Header, and Search. App is the overall parent component, it’s our App. It’s where all of the other components come to work together and make it function. The child component of App is the Header which holds its child component of Search. So to recap as a family tree, App is the grandparent, Header is the parent, and Search is the child or grandchild of App. Make sense? Basically, if we have a function or state variable we want to be used in Search but also render something in the App component then we would need to pass that function down from App to Search. We would do this using props! And it might look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*sIafd97-yFWqTa2UPhDpCg.png" /></figure><p>First, we set the state variable of search in the app and set it to an empty string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*tq-44LRCtpqeysztBpCMAg.png" /></figure><p>Then we pass it down to our header function. Side note: I created handleSearch as another function for a project but it’s not necessary for this explanation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*RCCjG_Y7Wx2Dp6fpc5SGfQ.png" /></figure><p>We then access Header and accept the props we passed down (Another note here: You can name your props whatever you want. Name your package. For me it helps to conceptualize what I am passing down and it’s what everyone will do instead of calling it props unless their app is really simple. Naming your props something else is vital to understanding what your code is doing).</p><p>From here we pass our search and handleSearch props to our Search bar component, the grandchild.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*7PGOC4BxJL0JEnZXuD9wGQ.png" /></figure><p>Boom! Now we pass down what we need from our props in order to get our search bar function to work in tandem with the rest of the app. Once I understood the importance of naming my props after the function of what I wanted it to do and component hierarchy, this opened the flood gates for how React apps work. It suddenly made so much more sense and helped me to process how I wanted my apps to work. It was a tremendously long process but, if you’re like me, the more you practice it the more you will understand it conceptually.</p><p>Now bear with me because there is one more concept I would like to hammer home and it is more a readability of your code issue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*yg8A6NRvbmuldzcGb8pMAg.png" /></figure><p>Let’s refer back to line 2 here. {props.name}. This is telling us that props has an attribute inside of it. Specifically a name. Here we are using dot notation to access what is nested inside of our props.</p><p>It becomes a matter of preference and how to clean up your code, but there are a number of different ways to destructure. You can set your props to a const and “destructure” what is inside like opening and taking out the contents of a package you have received in the mail. If, for instance, you’re destructuring an array with info in it like name, occupation, address it would look like:</p><p>const {name, occupation, address} = props</p><p>Then you would fill in the blank from there. For example, in our picture up above, instead of typing props.name you could just type in name. Neat!</p><p>Anyway, I hope this blog was helpful in understanding what props and destructuring are. It’s a ridiculously easy concept that sometimes isn’t explained well or just hard to grasp when learning how to code! Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fc8386dabf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Phase 1 Project: A Study in DOM Manipulation and Frustration]]></title>
            <link>https://medium.com/@mmtz2108/my-phase-1-project-a-study-in-dom-manipulation-and-frustration-a1e6231a9c63?source=rss-f05ac15eb117------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1e6231a9c63</guid>
            <category><![CDATA[beginner-coding]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Marcos Martinez]]></dc:creator>
            <pubDate>Fri, 22 Apr 2022 03:30:34 GMT</pubDate>
            <atom:updated>2022-04-22T03:30:34.369Z</atom:updated>
            <content:encoded><![CDATA[<p>When my partner and I first began our first phase project, we had dreams of grandeur. The assignment was simple, create a SPA (Single Page Application) with a minimum amount of event listeners, pull from an API, and combine your skills in HTML, CSS, and JS.</p><p>Initially, our ideas ranged from a cocktail database app that would give you drinks based on ingredients you had in your home to an activity generator that gave the user activities based on their level of boredom. Ultimately, we decided on an anime trivia app based on a public API we found and in the spirit of our shared interest in anime.</p><p>One day into working on our project, our egos firmly intact and inflated, we were informed we were not doing the project correctly. It was not dynamic enough. We had to pivot. I would imagine this would not be a huge deal for a seasoned developer but as students who only had the prework phase and 2.5 weeks of coding bootcamp under our belts… we were scrambling.</p><p>Unfortunately, our API was not much other than an anime fact database. That was it. It was recommended that we switch to creating a SPA that would do just that: generate anime facts. It seemed simple enough. However, we quickly came to a problem. How do we pull these facts onto the page from this API that was objects, arrays, and arrays of objects. Up until this point we had been using fetch calls with clearly defined databases in the comfort of labs and code challenges (nothing about a code challenge is comfortable). This probably should not have stumped us as much as it should have but alas, it was a process.</p><p>The structure was as follows:</p><pre>{<br>	success:true,<br>	data: [<br>		{<br>			anime_id: 1,<br>			anime_name: &quot;bleach&quot;,<br>			anime_img: &quot;https://eaxmpleimage.com/&quot;<br>		},<br>		{<br>			anime_id: 2,<br>			anime_name: &quot;black_clover&quot;,<br>			anime_img: &quot;https://eaxmpleimage2.com/&quot;<br>		},<br>		...<br>	]<br>}</pre><pre>{<br>	success:true,<br>	total_facts: 8,<br>	anime_img:&quot;https://eaxmpleimage.com/&quot;,<br>	data: [<br>		{<br>			fact_id: 1,<br>			fact: &quot;Ishvalans And Ametris Conflict Is Based On Hokkaido s Ainu People&quot;<br>		},<br>		{<br>			fact_id: 2,<br>			fact: &quot;Arakawa Actually Bought Military Prop Guns For Drawing References&quot;<br>		},<br>		...<br>	]<br>}</pre><p>It seems simple enough. But we initially struggled to get those anime facts, to isolate that data. We then to decided to create one button first. It would be a drop down menu that would list popular anime from the database and then display its facts when clicked on. The way in which we had to do this was through a fetch call that we had to make dynamic through our JS and HTML files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIrDMppyK9jS7w5ON0aB9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rDIzTsngNLdC-65hFb575A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bc_UAUp1fuz2u21OUmTNkQ.png" /></figure><p>This solved our fetch call as well as grabbing our dropdown menu while dynamically populating it from the HTML file. We were getting so caught up on the keyword data that we forgot that the API also had its own section called data that held the anime facts. The trick was, as you can see, to use data.data. We console logged it and found it was grabbing our facts. Now we just had to define what our renderFacts function was and to put it on the web page. Easy enough with a simple forEach array method that selects each anime and its data for us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*lD5TltQ8oHLrmcrg03AGMg.png" /></figure><p>Boom. That took care of a big ticket item for us. In hindsight, I’m embarrassed how long it took us to figure this out but the bottom line was that we did it. Our facts were rendering for each specific anime called. From there we decided to create a submit form for a comment section. I know, the idea is very 90s/early 2000s but we were desperate! However, submit forms are actually something I do enjoy making so here again is the code we came up with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPWp8EYiZ_PqWa_hRlqnTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*Z5qBxjdjXa827_HFeo46Xg.png" /></figure><p>Another big ticket item done. From here on, we were able to create a random fact button as well that drew from the array of animes but I will write about that another day once my partner and I have each presented this project. I will also update this blog as I update the project and make it more dynamic. All in all, this has been an incredibly humbling but educational experience and I hope to get even better as the bootcamp goes on. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1e6231a9c63" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>