<?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: Andrea Esparza</title>
    <description>The latest articles on DEV Community by Andrea Esparza (@andreaesparza13).</description>
    <link>https://dev.to/andreaesparza13</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%2F891004%2F9f283b98-9365-42c9-ace0-7b442f6c0111.png</url>
      <title>DEV Community: Andrea Esparza</title>
      <link>https://dev.to/andreaesparza13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andreaesparza13"/>
    <language>en</language>
    <item>
      <title>My Time At Flatiron School</title>
      <dc:creator>Andrea Esparza</dc:creator>
      <pubDate>Wed, 05 Oct 2022 17:57:22 +0000</pubDate>
      <link>https://dev.to/andreaesparza13/my-time-at-flatiron-school-16h2</link>
      <guid>https://dev.to/andreaesparza13/my-time-at-flatiron-school-16h2</guid>
      <description>&lt;p&gt;The past 15 weeks have been a whirlwind. I was, understandably, nervous about starting a bootcamp, but I don't regret it at all. My goal is to dive into each phase of the course and what I learned. While Phase 1 feels like a lifetime ago, I'll start there.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 1: JavaScript
&lt;/h4&gt;

&lt;p&gt;Phase 1 was tough simply because it was first. It was completely new to me, they threw a million different things at us, and it moved really fast. We learned how to write functions and manipulate the DOM in two weeks. &lt;em&gt;Note to self: go back and try that code challenge again.&lt;/em&gt; I was lost for most of it, I felt like I was always behind, and the lectures seemed irrelevant. By the time week 3 rolled around and we had to create our first project, things started to click. It wasn't until phase 2, though, when I felt comfortable calling it "vanilla" JavaScript.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 2: React
&lt;/h4&gt;

&lt;p&gt;The moment we were introduced to React, my world turned upside down. I really struggled to understand JS, but now it made way more sense. We learned how to write JSX, update state, and build components. It made such a difference for me during the code challenge and project. During this phase, I really began to appreciate our instructors and their lectures. It finally clicked for me that lectures were one big "putting it all together lab" during this phase. &lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 3 and 4: Ruby and Ruby on Rails
&lt;/h4&gt;

&lt;p&gt;I'm putting these together because they go together. Similarly to the transition from JS to React, going from Ruby to Rails made a lot of things make sense. In Ruby, we learned about SQL and object relational mapping (ORM), Sinatra, and Active Record. We learned how to make queries and create databases, but it wasn't until we got to Rails that we really took off. With Rails, we were able to do the same stuff as Ruby but faster and more efficiently. Which left room for higher level topics. We learned about user authorization and authentication, RESTful routing, and building a full-stack application with a React frontend and a Rails backend. &lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 5: Capstone Projects
&lt;/h4&gt;

&lt;p&gt;The phase 4 project was special because it was a) our last group project, and b) our capstone would be very similar in size. Working on this project has been a rollercoaster between "I know exactly what I'm doing" and "what does that mean!?!?!" My cohort has developed a very tight relationship so we have helped each other out. It's been fun watching everyone create something they are proud of. &lt;/p&gt;

&lt;p&gt;As I get ready to present my project, I am filled with nostalgia. I said earlier that phase 1 feels like a lifetime ago. My life before that feels even farther. I am so glad I signed up for this program.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Basics of Rails Generators</title>
      <dc:creator>Andrea Esparza</dc:creator>
      <pubDate>Thu, 15 Sep 2022 16:22:12 +0000</pubDate>
      <link>https://dev.to/andreaesparza13/basics-of-rails-generators-4cjh</link>
      <guid>https://dev.to/andreaesparza13/basics-of-rails-generators-4cjh</guid>
      <description>&lt;p&gt;Rails generators have become common practice for me since we started learning Rails because they have streamlined the process of creating files. The purpose of this blog is to have a descriptive list of the different generators available. Above all, Rails generators are terminal commands. If you follow their rules and conventions, you will be able to use them efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Set Up
&lt;/h2&gt;

&lt;p&gt;Before you start typing terminal commands, it's important to know what you are going to create. If you are creating a table, make sure you know the name of the table, the names of the columns, and the datatype for each column. While it's not obligatory to write out every piece of information in the terminal, it does make it more efficient. For each table we follow our MVC - Model, View, Controller. Therefore, we will be creating a model, a controller, and a serializer for each table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model
&lt;/h3&gt;

&lt;p&gt;The first generator on the list is the model. This needs to be first because it's the piece of the puzzle that sets up our table and its columns. To create the model, run this command:&lt;br&gt;
&lt;code&gt;$ rails generate model table_name column_a:datatype column_b:datatype&lt;/code&gt; and so on. This command also creates the migration that goes with the model.&lt;/p&gt;

&lt;p&gt;One of my favorite things about Rails is that it lets us use 'g' instead of typing 'generate.' It also sets the default datatype to be string, so you don't need to specify that one. All other datatypes need to be specified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controller
&lt;/h3&gt;

&lt;p&gt;The controller is the middle-person between the model and the view. We can create it using a rails generator as follows:&lt;br&gt;
&lt;code&gt;$ rails g controller table_name&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  View
&lt;/h3&gt;

&lt;p&gt;For the view side of things, we use serializers. Therefore, we will use this command: &lt;br&gt;
&lt;code&gt;$ rails g serializer table_name&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  There's gotta be another way...
&lt;/h3&gt;

&lt;p&gt;There is! When you are setting up a Rails application and you know that you're going to need a model, a controller, and a serializer, we can use a resource generator.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resource
&lt;/h3&gt;

&lt;p&gt;The resource generator takes care of creating a model, a controller, a serializer, a migration, a test suite, and adds the route. The command looks like this:&lt;br&gt;
&lt;code&gt;$ rails g resource table_name column_a:datatype column_b:datatype&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What if I mess up?
&lt;/h3&gt;

&lt;p&gt;If you make a mistake or need to redo any of these generators, we can use the drop command as such:&lt;br&gt;
&lt;code&gt;$ rails drop [generator] table_name&lt;/code&gt;&lt;br&gt;
The generator depends on what you need to drop, whether it be a model, a controller, a serializer, or a resource. And again, Rails lets us use 'd' instead of the word 'drop.'&lt;/p&gt;

&lt;h3&gt;
  
  
  Final thoughts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Rails generators are a way of creating files through the terminal, but it doesn't mean it's the only way of doing things. &lt;/li&gt;
&lt;li&gt;At Flatiron, we've learned to add &lt;code&gt;--no-test-framework&lt;/code&gt; at the end of our rails generator commands so we don't mess with the existing test suites.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Instance vs Class Methods in Ruby</title>
      <dc:creator>Andrea Esparza</dc:creator>
      <pubDate>Wed, 24 Aug 2022 15:56:04 +0000</pubDate>
      <link>https://dev.to/andreaesparza13/instance-vs-class-methods-in-ruby-4amj</link>
      <guid>https://dev.to/andreaesparza13/instance-vs-class-methods-in-ruby-4amj</guid>
      <description>&lt;p&gt;The term "self" in Ruby was one of the toughest things to wrap my head around. There are times when "self" refers to a class and there are times when "self" refers to an instance of that class, which affects the way we write methods.&lt;/p&gt;

&lt;h1&gt;
  
  
  Classes and Instances
&lt;/h1&gt;

&lt;p&gt;To understand instance and class methods, let's first dissect what instances and classes actually are. A class, essentially, is a collection of instances. If we think about it along with the database, the class represents the overall table and the instances represent each row of that table.&lt;/p&gt;

&lt;h1&gt;
  
  
  Instance vs Class Methods
&lt;/h1&gt;

&lt;p&gt;Now that we understand how instances and classes are related, we can talk about methods. Methods are what we use to manipulate and extrapolate details from our database. We can create methods to find, sort, delete, and so much more. The million dollar question becomes "do we want our method to affect the class as a whole, or do we want our method to affect each instance?"&lt;/p&gt;

&lt;h3&gt;
  
  
  Class Methods
&lt;/h3&gt;

&lt;p&gt;If we want our method to affect our class as a whole, then we need to write a class method. Class methods are usually presented with a period, such as &lt;code&gt;ClassName.method_name&lt;/code&gt;. This let's us know that our "self" is the class, so our code would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ClassName
   def self.method_name
      ClassName.method
   end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Instance Methods
&lt;/h3&gt;

&lt;p&gt;If we want our method to affect each instance of the class, then we need to write an instance method. Instance methods are usually presented with a hashtag, such as &lt;code&gt;ClassName#method_name&lt;/code&gt;. This let's us know that our "self" is the instance, so our code would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ClassName
   def method_name
      self.method
   end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Umm, okay but I'm still confused
&lt;/h4&gt;

&lt;p&gt;If you're still feeling like this "self" thing is daunting, I recommend using a console to test things out. At Flatiron, we've been encouraged to start a pry session to test our methods out in the console. For class methods, we type &lt;code&gt;ClassName.method_name&lt;/code&gt;. For instance methods, we need to think of a specific instance to test. One built in case is the "first" instance. That would be the first row of the table. So when testing methods in the console, we can type &lt;code&gt;ClassName.first.method_name&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;I'll leave you with something that I've repeated to myself many times: class methods affect the whole class, a.k.a. the whole table; instance methods affect an instance &lt;em&gt;of the class&lt;/em&gt;, a.k.a. a row of the table.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Search Bar Functionality Using State In React</title>
      <dc:creator>Andrea Esparza</dc:creator>
      <pubDate>Wed, 03 Aug 2022 00:20:00 +0000</pubDate>
      <link>https://dev.to/andreaesparza13/search-bar-functionality-using-state-in-react-25kj</link>
      <guid>https://dev.to/andreaesparza13/search-bar-functionality-using-state-in-react-25kj</guid>
      <description>&lt;p&gt;Adding a search bar is one of the most user friendly components of a website. Without it, users would be sifting through countless items trying to find what they are looking for. Luckily adding one only takes a few steps. &lt;/p&gt;

&lt;h2&gt;
  
  
  State
&lt;/h2&gt;

&lt;p&gt;First and foremost, we need to import &lt;code&gt;useState&lt;/code&gt; with React. &lt;code&gt;useState&lt;/code&gt; is going to let us change the target value to match what the user types in the search bar. Without &lt;code&gt;useState&lt;/code&gt;, we wouldn't be able to keep track of that change. Along with importing &lt;code&gt;useState&lt;/code&gt;, we need to define our state variables.  In this case, our default state will be an empty string since users will type strings into the search bar.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k4cNjk1C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvy9tz3praj6yrojv6fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k4cNjk1C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvy9tz3praj6yrojv6fw.png" alt="Step 1" width="880" height="217"&gt;&lt;/a&gt; While the name of the variables doesn't truly matter, convention dictates that we use the pattern demonstrated in the image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filtering Array
&lt;/h2&gt;

&lt;p&gt;The next step in the process is to filter the existing array so that our search query can match the string the user types to it. Our updated code should look something like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TqkrS_RL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73tje88fps97apwrbwuq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TqkrS_RL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73tje88fps97apwrbwuq.png" alt="Step 2" width="880" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Handler
&lt;/h2&gt;

&lt;p&gt;Since our state depends on user input, we can use an event handler to alter our state. I personally prefer to declare the function outside of the return so the JSX is more legible. In this case, we can use an &lt;code&gt;onChange&lt;/code&gt; event since the user input is a type of change. Thus, our code should look as follows:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vcu59_EY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0wt20gmiydg0myh3r7k8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vcu59_EY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0wt20gmiydg0myh3r7k8.png" alt="Step 3" width="880" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering Array
&lt;/h2&gt;

&lt;p&gt;The final step in this process is to render content. If we return our original array, the search won't work because it's not being affected, therefore we need to render our &lt;em&gt;altered&lt;/em&gt; array, which is named &lt;code&gt;filteredArray&lt;/code&gt; in this case. Here's what our code should look in the end:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PwblptvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/toa1fb2f6808dko1300i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PwblptvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/toa1fb2f6808dko1300i.png" alt="Step 4" width="880" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Cases
&lt;/h2&gt;

&lt;p&gt;In the example above, the array consisted of numbers. When dealing with letters, we need to add a check in the form of &lt;code&gt;.toLowerCase()&lt;/code&gt; so the user can input any letter in any case and it won't affect the search. It should look as follows:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g3I7BqDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vasc4wuuki0j5nan7j1e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g3I7BqDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vasc4wuuki0j5nan7j1e.png" alt="Extra" width="880" height="563"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Navigating the Terminal for the First Time (on a Mac)</title>
      <dc:creator>Andrea Esparza</dc:creator>
      <pubDate>Wed, 13 Jul 2022 04:02:20 +0000</pubDate>
      <link>https://dev.to/andreaesparza13/navigating-the-terminal-for-the-first-time-on-a-mac-2ihg</link>
      <guid>https://dev.to/andreaesparza13/navigating-the-terminal-for-the-first-time-on-a-mac-2ihg</guid>
      <description>&lt;p&gt;Many years ago, I watched a friend of mine access a file in my computer using solely the terminal and it blew my mind. She moved so quickly and was unfazed by what seemed like gibberish to me. I remember thinking there was no way I could ever do that. And yet I am here now, by no means an expert, feeling confident that I can get from point A to point B using only terminal commands. &lt;/p&gt;

&lt;h3&gt;
  
  
  Opening the Terminal
&lt;/h3&gt;

&lt;p&gt;Starting from the very beginning, it's important that you, the user, are feeling confident as soon as that terminal window pops up.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IROkURFK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pbmfrgudgdm7efsqmmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IROkURFK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pbmfrgudgdm7efsqmmh.png" alt="Image description" width="880" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Print Working Directory
&lt;/h3&gt;

&lt;p&gt;Now is the time to introduce our first command (don't type the "~"):&lt;br&gt;
&lt;code&gt;~ pwd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;"pwd" stands for "print working directory," which is not very helpful if you've never done this before. What "pwd" does is it shows you a path from the very beginning to where you are now. It might not show much the first time you run it:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_zgCZXCn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/paydb9pjppksjv790e7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_zgCZXCn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/paydb9pjppksjv790e7h.png" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;br&gt;
That just means I am at the beginning and there is no other folder (or directory) left.&lt;/p&gt;

&lt;h3&gt;
  
  
  List Directories
&lt;/h3&gt;

&lt;p&gt;Let's take a look at our next command (again, don't type the "~"):&lt;br&gt;
&lt;code&gt;~ ls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's a lowercase L as in Larry, by the way. "ls" means "list", as in list all the folders (directories) ahead of us. It's a list of ~&lt;em&gt;possibilities&lt;/em&gt;~.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EddctuRu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2k7ap1i7fq40796las3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EddctuRu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2k7ap1i7fq40796las3.png" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"pwd" and "ls" are both very helpful to see where we are, where we've been, and where we can go in the terminal. &lt;/p&gt;

&lt;h3&gt;
  
  
  Change Directory
&lt;/h3&gt;

&lt;p&gt;Buuuuuut those two don't actually do anything or take us anywhere. That's where this next command comes in (don't type the "~" or the brackets):&lt;br&gt;
&lt;code&gt;~ cd [directory-name]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;"cd" (to me) means "go to." It actually stands for "change directory" but you already know how I feel about that word by now. So if we look at the image above one more time, we can navigate to "Users" by typing the following command:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gba0e-kA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ngeq74tqjq4g89iti9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gba0e-kA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ngeq74tqjq4g89iti9x.png" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;br&gt;
The change here is subtle, but you can see the "/Users" is now before the "%" meaning we are inside of the directory (ugh) called Users.&lt;/p&gt;

&lt;p&gt;There are &lt;strong&gt;many&lt;/strong&gt; other commands in the terminal, but these three are the ones I use the most and I think are the most essential. &lt;/p&gt;

&lt;p&gt;Tl;dr&lt;br&gt;
&lt;code&gt;pwd&lt;/code&gt; to see where you are and where you've been&lt;br&gt;
&lt;code&gt;ls&lt;/code&gt; to see where you can go&lt;br&gt;
&lt;code&gt;cd&lt;/code&gt; to go!&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
