<?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 Samantha Crespo on Medium]]></title>
        <description><![CDATA[Stories by Samantha Crespo on Medium]]></description>
        <link>https://medium.com/@samkcrespo?source=rss-2d488cd5a767------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_KNpy3Y3-9PGHXz-gNIWTA@2x.jpeg</url>
            <title>Stories by Samantha Crespo on Medium</title>
            <link>https://medium.com/@samkcrespo?source=rss-2d488cd5a767------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 11:43:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samkcrespo/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[CRUD Tutorial — Ruby on Rails]]></title>
            <link>https://medium.com/@samkcrespo/crud-tutorial-ruby-on-rails-d7ee332e31c0?source=rss-2d488cd5a767------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7ee332e31c0</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Samantha Crespo]]></dc:creator>
            <pubDate>Wed, 29 Jun 2022 23:50:56 GMT</pubDate>
            <atom:updated>2022-06-29T23:50:56.916Z</atom:updated>
            <content:encoded><![CDATA[<p>CRUD Tutorial — Ruby on Rails</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fYWKHv6IJnrKjfLlZTYFw.jpeg" /><figcaption>Rails logo</figcaption></figure><p>Ruby on Rails is a full stack <a href="https://www.techtarget.com/whatis/definition/open-source">open source</a> framework for Web development in <a href="https://www.techtarget.com/whatis/definition/Ruby">Ruby</a>, an object-oriented programming (OOP) language.</p><p>In this tutorial, I am going to walk through how I created a Rails application with full CRUD capabilities, and demonstrate how Rails communicates with the database of your choice. (SQLite, PostgreSQL, etc.)</p><ol><li>To start, we will create a new Rails application using the following command:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*flT33wI-yx4dzA6xgn31oQ.png" /><figcaption>create a new rails application using this command. -T will disregard creating test files.</figcaption></figure><p>This command will create all the files and folders required by a new Rails app.<br>Then, it’s fetching gems and bundling them; these are the dependencies that Rails needs in order to run your website in its simplest iteration.</p><p>2. Once all files have been created and gems have been bundled, you will need to run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*8GvF8ZbOqz-6MDJq9e1w0A.png" /><figcaption>cd into newly created application, and open in VScode</figcaption></figure><p>This will open your new application in VSCode, — check out you all of the files that were created for you. Nice!</p><figure><img alt="Files created when running rails new command" src="https://cdn-images-1.medium.com/max/782/1*jmxgTdlayZuh89GT_99ZRQ.jpeg" /><figcaption>Files created when running rails new command</figcaption></figure><p>3. At this point, you are ready to create your Models &amp; Controllers. There are several ways to do this, but my preference is using the rails g resource command. This will create a migration with your specified columns and their data type, a model, controller, and all of the routes needed for full CRUD capabilities. (See below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*ztUYgmu4GzOvjV7fcAvoqw.png" /></figure><p>4. Let’s create some seed data! Add your seed data in the seeds.rb file like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*cpi22kquqLHaFCMUj0IsfA.png" /></figure><p>5. Run your migration/s and seeds:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*BUN8n9w2lvEkyxXq_sMT_Q.png" /></figure><p>6. It’s best practice to test your data in the console. The simplest way to do so is by running the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*n4c92DK4xT4MQ9Wh5BcYqA.png" /><figcaption>open rails console, then view volunteers data by running .all command</figcaption></figure><p>7. Check your routes by running the rails routes command in your terminal. The rails g resource command is going to give you all routes needed for full CRUD. It’s not always necessary to have full CRUD capabilities for every model, so you can specify which actions by going to config/routes.rb and adding the specific routes you need to your resources :volunteers code — &gt; only: [:index, :show ]</p><p>I am demonstrating full CRUD, so I will be leaving my routes file the way it was generated with our rails g resource command, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*AycEMuePervZuR4veoFclg.png" /><figcaption>resources :volunteers gives us all the routes needed for full CRUD</figcaption></figure><p>8. Next up, creating our CRUD actions in the controller! This is my favorite part. CRUD stands for Create, Read, Update, Delete. For these actions, you will be navigating to app/controllers. I like to start with the ApplicationController and input any error handling first. All controllers inherit from ApplicationController, so this will ensure that our code meets the DRY standards, instead of writing error handling functions for each model controller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7RWM1f_xeUu6Z9E13hnhw.png" /><figcaption>error handling, in application_controller.rb file</figcaption></figure><p>9. Error handling is out of the way! Now, we are going to create our CRUD methods to match our corresponding routes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncQwQeCw5L9aBVppZtXDwg.png" /></figure><p>10. Now that all of our routes have a corresponding method, your application has full CRUD capabilities. Test out your routes using the browser and postman, and pat yourself on the back! You’ve just created the MC in MVC. (Ruby on Rails uses the Model-View-Controller (MVC) architectural pattern. MVC is a pattern for the architecture of a software application.)</p><p>If you are curious about the before_action and strong params that were used in my volunteers_controller, check out the following links!</p><p><em>Filters: </em><a href="https://guides.rubyonrails.org/action_controller_overview.html#filters"><em>https://guides.rubyonrails.org/action_controller_overview.html#filters</em></a><em><br>Strong parameters: <br></em><a href="https://api.rubyonrails.org/classes/ActionController/StrongParameters.html"><em>https://api.rubyonrails.org/classes/ActionController/StrongParameters.html</em></a></p><p>Thanks for reading and happy coding! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7ee332e31c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ActiveRecord — CRUD]]></title>
            <link>https://medium.com/@samkcrespo/activerecord-crud-d33da09841f6?source=rss-2d488cd5a767------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33da09841f6</guid>
            <category><![CDATA[activerecord]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rubygems]]></category>
            <dc:creator><![CDATA[Samantha Crespo]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 01:03:38 GMT</pubDate>
            <atom:updated>2022-06-07T17:12:08.270Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*oI91rs0VPmQYfhm7lbFm0A.png" /></figure><h3>ActiveRecord — CRUD</h3><p>I recently learned SQL, only <em>after</em> learning it was I introduced to ActiveRecord. It makes sense why it’s important to at least have a basic understanding of SQL prior to learning ActiveRecord, so that you can understand what’s going on under the hood, but boy does AR make everything better.</p><p>ActiveRecord comes with built-in methods. Each of these built-in methods will allow you to perform queries/CRUD actions on your database without writing raw SQL. While AR has so many great built-in methods to offer, I’m going to focus on showing how it simplifies basic CRUD actions for now.</p><p>Below you will find CRUD actions using SQL, &amp; then how to do the same action using <em>much less code</em> with ActiveRecord.</p><p><strong>C, Create: INSERT INTO…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*UC4OGMo3kwvEWRWXRYTWuQ.jpeg" /><figcaption>SQL — Create/Insert Into</figcaption></figure><p><strong>R, Read: SELECT… FROM …</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*2LGaI24PXmgm-RfmhLOc5w.jpeg" /><figcaption>SQL — Read/Select (Shown two ways)</figcaption></figure><p><strong>U, Update: UPDATE FROM… WHERE</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*bkzfTrCP8sQkj6oFHD6STg.jpeg" /><figcaption>SQL — Update</figcaption></figure><p><strong>D, Delete/destroy: DELETE FROM… WHERE</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*04p8XL6rFyY3qmNJPLGnlg.jpeg" /><figcaption>SQL — Delete</figcaption></figure><p>Performing the same actions in Active Record methods will look something like this…</p><p><strong>C, Create: .create()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*IMoFItWXHyASybCnMLH25Q.jpeg" /><figcaption>Active Record — Create | .create()</figcaption></figure><p><strong>R, Read: .all</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6d7Zk0lbWkmFAgGC3T9ENQ.jpeg" /><figcaption>ActiveRecord— Read | .all</figcaption></figure><p><strong>U, Update: .update()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*yJkKUuK5pLQemwOKy_b70g.jpeg" /><figcaption>ActiveRecord — Update | .update(column: newData)</figcaption></figure><p><strong>D, Delete/destroy: .delete() | .destroy()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*XPX5HF_ByTCwnt-8nvS8rQ.jpeg" /><figcaption>ActiveRecord — Destroy | .destroy(id)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KeREUJnidP-WWoVnTNUTjA.jpeg" /><figcaption>ActiveRecord — Delete | .delete(id)</figcaption></figure><p><em>*Delete and Destroy ARE different. Take a look at this blog that simply explains the difference → </em><a href="https://medium.com/@wkhearn/delete-vs-destroy-does-it-even-matter-8cb4db6aa660"><em>https://medium.com/@wkhearn/delete-vs-destroy-does-it-even-matter-8cb4db6aa660</em></a></p><p>The key takeaway here, is that Active Record allows you be more productive by writing less code, as it provides easy-to-use abstractions for working with databases.</p><p>This is just the tip of the iceberg of everything that you get for free when using the AR gem — For more details on how to use AR and everything that you can do with it, check out the official ruby guides that I linked at the bottom of this post.</p><p>Thanks for reading! :)</p><ul><li><a href="https://guides.rubyonrails.org/active_record_basics.html">Active Record Basics - Ruby on Rails Guides</a></li><li><a href="https://guides.rubyonrails.org/active_record_querying.html">Active Record Query Interface - Ruby on Rails Guides</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33da09841f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use State in React Components]]></title>
            <link>https://medium.com/@samkcrespo/use-state-in-react-components-b7ff1ef67d04?source=rss-2d488cd5a767------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7ff1ef67d04</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Samantha Crespo]]></dc:creator>
            <pubDate>Mon, 16 May 2022 16:04:34 GMT</pubDate>
            <atom:updated>2022-05-16T16:04:34.981Z</atom:updated>
            <content:encoded><![CDATA[<p>React class components have a class that holds their state. They provide a method you can use to update the state, triggering a re-render.</p><p>State can now be used when working with Functional Component’s - you will need to use the useState() hook. (Hooks were added to React 16.8) From this point forward, I will be discussing using State in <em>functional components</em>.</p><p>Great! <strong>So, what is <em>state!</em>?</strong> The state object is where you store property values that belong to the component. When a value in the state changes, the component will re-render. Using state boosts performance by avoiding unnecessary re-renders.</p><p><strong>To get started</strong>, the hook will need to be imported into the component that will hold state. [Line 1 of below example]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*N2BPmUUSjDP1VcsbrT3i9Q.png" /><figcaption>Import useState hook — Destructure returned values</figcaption></figure><p>Next, we need to initialize our state by calling useState inside of our component.</p><p>useState accepts an initial state and returns two values:</p><p>1. The first value, <strong>our current state.</strong> In the example above, that would be recipeData.<br>2. The second value, setRecipeData, is a <strong>function that is used to update our state. </strong><br>3. Lastly, we must set our default/initial state. In this instance, it is an empty array, as our recipeData is an array of objects that we will be fetching for.</p><p>Now we can update our state! This is where our setter function comes in to play. setState() schedules an update to a component’s state object. When state changes, the component responds by re-rendering.</p><p>State is one of the most important concepts for React developers to understand. It is<strong> also</strong> important to understand when, where and how to use state in your applications so that it is properly managed. You will hear the phrase ‘single source of truth’ and this must not be taken lightly. Read more on that here. <a href="https://reactjs.org/docs/lifting-state-up.html#lessons-learned">https://reactjs.org/docs/lifting-state-up.html#lessons-learned</a></p><p>Now, it’s your turn to try it out! :) Start with a counter — for me, this really solidified what state was and how it works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7ff1ef67d04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Software Engineering Journey [JavaScript]: Phase-1‍]]></title>
            <link>https://medium.com/@samkcrespo/my-software-engineering-journey-javascript-phase-1-f3e108b7e8f0?source=rss-2d488cd5a767------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e108b7e8f0</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Samantha Crespo]]></dc:creator>
            <pubDate>Sun, 24 Apr 2022 19:26:09 GMT</pubDate>
            <atom:updated>2022-04-24T19:31:14.952Z</atom:updated>
            <content:encoded><![CDATA[<p>My Software Engineering Journey [JavaScript]: Phase-1👩🏼‍💻</p><figure><img alt="Person working on computer" src="https://cdn-images-1.medium.com/max/1024/1*ii1gWBtZp4E6MuivIMhdGg.jpeg" /></figure><p>I enrolled into a software engineering program at Flatiron School that started on April 4th. While I’ve been in the program for just 3 weeks, I’m quite astonished by how much I have learned so far. I also can’t believe that Phase-1 has now come and gone and we are already going in to Phase-2! To wrap up Phase-1, we had a code challenge &amp; a group project. The code challenge was an emotional rollercoaster, but I did it! The best part about the final week of the first phase though was, by far, the project.</p><p>The project that my team and I came up with was a Single Page Application (<strong>SPA</strong>), that was social media inspired in which you can interact with different memes by adding witty caption/comments to each one. During the brainstorming of our idea we discussed how, often times, the comments on social media posts are often better than the posts themselves and thus, ‘Caption This Meme’ was born.</p><figure><img alt="Screenshot of group project ‘Caption This Meme’ SPA" src="https://cdn-images-1.medium.com/max/882/1*5kZdHz5c1-vyjxRYiZO3pg.png" /></figure><p>For our project, we implemented several important techniques that were taught in the curriculum.</p><p><strong>Fetch/GET request:</strong> The first thing that we did is found an API of meme images. We used this API’s data to render our meme’s to our page.</p><p><strong>Array Method:</strong> Once we got our data and used console.log to see how this data was formatted, we noticed that the data was nested. We used dot notation so that we were only getting the data that we actually needed back. At this point, we decided that we only wanted about 6–10 memes to start out with. We later adjusted our code to pull more, but had initially used a slice method to return a new array with the specified amount of images.</p><figure><img alt="Fetch request. To imgFlip API" src="https://cdn-images-1.medium.com/max/632/1*gXFyUuwnTez5Su6FqViZow.png" /></figure><p><strong>Array Iteration:</strong> Once we had our data, we knew that we needed to use array iteration to render each meme to the page. For this, we used a forEach(). A forEach() calls a provided callback function <em>once</em> for each element in an array.</p><p><strong>DOM Manipulation: </strong>The callback function that we provided our forEach,<strong> </strong>created and appended elements that each meme needed to have - an image, a like button, and a form so that each Meme had it’s own functionality.</p><p>We had created a div in our HTML that we intended to be our meme “container”, to “hold” all of this code that our function created. In the HTML, we gave our div an id of meme-container. (The more specific, the better!) We then created a container variable, and used querySelector to target our div.</p><p>Finally, we appended our new elements to our div container using .append()</p><p><em>container.append(image, span, btn, ul, form)</em></p><figure><img alt="Array iteration &amp; DOM manipulation" src="https://cdn-images-1.medium.com/max/652/1*XQPXxFpDePF7PnnX0mpUrg.png" /></figure><p><strong>Event Listeners:</strong> Our data and elements were now successfully showing on the page! Yay! But, we weren’t done yet. We needed to add a few event listeners to make the users experience more interactive.</p><p>Event Listeners are very important. They allow us to add interactive functionality to elements, by listening to different “events” that take place on a page. An event listener takes two parameters. The event that it is listening for (click, load, mouseover, keydown, etc.) and a callback function. The second argument (cb function) is only called when the described event gets fired.</p><p><strong>The event listeners that we used were;</strong><br> 1. A click event for the like button — once clicked, our events cb function used a counter and .innerText to update how many likes the meme had received.</p><figure><img alt="Like Button: addEventListener code block" src="https://cdn-images-1.medium.com/max/465/1*4irp2Xl6FcN5Gpd5B1yB9g.png" /></figure><p>2. A submit event for the form — once the form was submitted, the cb function created an li, it then set the new li’s .innerText to be the value of the text entered into the forms input using e.target.comment.value, and finally the li was appended to the ul that was created for that meme.</p><figure><img alt="Form: addEventListener code block" src="https://cdn-images-1.medium.com/max/521/1*dAPQ_l02f8gaGGtn_2qBnA.png" /></figure><p>3. A mouseover &amp; mouseout event on the meme(img) — We wanted a user to be able to enlarge an image, but then set the image back to its original size when they were no longer ‘mousing over’ the meme without having to minimize it themselves. This event was really simple, and none of us had ever used it before. A quick google search had us implementing this function in less than 5 minutes. (We are also learning to become masters at googling😼)</p><figure><img alt="Image: addEventListeners code block" src="https://cdn-images-1.medium.com/max/462/1*yMQnWJxcn5m6H012PAX-2w.png" /></figure><p>We only had about 4 and a half days to complete this project, while also studying hard for a code challenge — so there were certainly many things that we discussed adding that got left out. We didn’t add as much styling as we would have liked, and also really wanted to have our like button in the shape of a heart. (Using font-awesome icons) Another idea that we had was to add a favorite icon that changed color once clicked, and added the favorited memes into a new section of the page.</p><p>All in all, the project was so much fun and it really put into perspective how much we have learned in just three short weeks. I can’t wait to learn more!</p><p>Thanks for reading! ☺️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e108b7e8f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>