<?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: Lesly Juarez</title>
    <description>The latest articles on DEV Community by Lesly Juarez (@jlesly).</description>
    <link>https://dev.to/jlesly</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F580304%2F5fed79bc-f5ed-48b4-97f2-da757b244714.jpeg</url>
      <title>DEV Community: Lesly Juarez</title>
      <link>https://dev.to/jlesly</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jlesly"/>
    <language>en</language>
    <item>
      <title>CoffeeCoffeeCoffee</title>
      <dc:creator>Lesly Juarez</dc:creator>
      <pubDate>Wed, 08 Mar 2023 17:59:36 +0000</pubDate>
      <link>https://dev.to/jlesly/coffeecoffeecoffee-503j</link>
      <guid>https://dev.to/jlesly/coffeecoffeecoffee-503j</guid>
      <description>&lt;p&gt;For this project I wanted to create a web application that would allow users to keep track of the espresso they brew. A user would be able to add a brewing entry, edit the brewing entry and include information about the equipment used. A user would also be able to add comments to the entry.&lt;/p&gt;

&lt;p&gt;Models&lt;/p&gt;

&lt;p&gt;User has_secure_password has_many :brews has_many :comments has_many :brew_comments, through: :brews, source: :comments&lt;/p&gt;

&lt;p&gt;Brew belongs_to :user belongs_to :equipment has_many :comments has_many :users_commented, through: :comments, source: :user&lt;/p&gt;

&lt;p&gt;Comment belongs_to :user belongs_to :brew&lt;/p&gt;

&lt;p&gt;Equipment has_many :brews&lt;/p&gt;

&lt;p&gt;rails generate resource&lt;/p&gt;

&lt;p&gt;I wanted to allow the user to add information about the equipment they used to brew the coffee. I created another migration Equipment that had accepted brand_model as a string.&lt;/p&gt;

&lt;p&gt;OmniAuth I used this &lt;a href="https://medium.com/swlh/google-authentication-strategy-for-rails-5-application-cd37947d2b1b"&gt;blog post&lt;/a&gt; to setup a social login for my web application. I followed the instructions by creating an app in Google Developers Console and started the rails server to make sure it was working properly so far. I received the following error: &lt;code&gt;No route matches [GET] “/auth/google_oauth2&lt;/code&gt;. After checking for spelling errors in the routes and views I checked the authorized redirect URIs I had listed in the credentials section of the Google Developers Console. I was finally able to find a Stack Overflow &lt;a href="https://stackoverflow.com/questions/65783394/no-route-matches-get-auth-google-oauth2-error-keeps-coming-up"&gt;question&lt;/a&gt; with a similar issue. The suggested &lt;a href="https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284"&gt;solution&lt;/a&gt; was to add:&lt;/p&gt;

&lt;h1&gt;
  
  
  Gemfile
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem 'omniauth-rails_csrf_protection'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step entailed changing links to POST requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;link_to "Log In with Google", "/auth/google_oauth2", method: :post
# or
button_to link_to "Log In with Google", "/auth/google_oauth2"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above worked! I ran the rails server and I didn’t get the error I kept getting earlier.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mod 3</title>
      <dc:creator>Lesly Juarez</dc:creator>
      <pubDate>Sat, 30 Apr 2022 12:50:30 +0000</pubDate>
      <link>https://dev.to/jlesly/mod-3-2mnb</link>
      <guid>https://dev.to/jlesly/mod-3-2mnb</guid>
      <description>&lt;p&gt;The idea for this project came into existence after misplacing a notebook that I used to keep track of the different kinds of coffee and the brewing methods used. Owning a Breville espresso machine has turned making coffee into a science experiment. There are many variables that can affect the taste of coffee such as the the amount of coffee beans (dose) used for a single cup of coffee. The grind size also affects the taste tremendously.BrewCoffee is an application that allows coffee enthusiasts to keep a list of information about the coffee brewing process. A user can create a new account by typing in a username and password or by using their Google account information. Once a user has logged in they can add a new entry by filling out the form that requires the following information: name of coffee, brand of coffee, grind size, dose (grams), extraction time (seconds), extraction value (grams), and equipment type. The user can select from a list of equipment in the database or add a new equipment. To add a new equipment a user will need to fill out the form requiring information about the brand and model. A user can also add a comment to a brew entry by clicking comment after the brew form has been submitted. When a user logs out they are brought back to the homepage to login.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Vinyl17</title>
      <dc:creator>Lesly Juarez</dc:creator>
      <pubDate>Mon, 25 Apr 2022 01:54:41 +0000</pubDate>
      <link>https://dev.to/jlesly/vinyl17-32n4</link>
      <guid>https://dev.to/jlesly/vinyl17-32n4</guid>
      <description>&lt;p&gt;I was inspired to create an application that would allow a user to keep track of their vinyl record collection. The user is able to add a new vinyl to their collection by providing an artist name, album name, year, and genre. The user can browse the collection by genre. A user can also delete a vinyl record from their collection. The application also has a list of resources about vinyl records.&lt;/p&gt;

&lt;p&gt;Here are a few notes that I took while bringing this project to life. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Back-End&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I created a new rails application with an API using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails new PROJECT_backend --api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I created a github repository for only the backend and added models, seed data, ran migrations, created the controllers, uncommented CORS, and lastly added the fast jsonapi gem. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Front-End&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I double checked my routes and moved on to the frontend of the application by creating a new React application using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app PROJECT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used the following commands to install react-redux.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-redux
npm intall redux
npm install redux-thunk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installed React Router v5&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install react-router-dom@5&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;npm start&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;starts the development server &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mod 4</title>
      <dc:creator>Lesly Juarez</dc:creator>
      <pubDate>Mon, 17 Jan 2022 21:50:04 +0000</pubDate>
      <link>https://dev.to/jlesly/mod-4-2lg8</link>
      <guid>https://dev.to/jlesly/mod-4-2lg8</guid>
      <description>&lt;p&gt;For this project I wanted to build a Single Page Application that would display a trivia game for my significant other. The backend was built with Rails API and the frontend with HTML, CSS, and JavaScript. A user has three categories to select from to start the game. When a user selects a category they get a "Good Luck!" alert and the questions for that category are rendered. Once the user finishes the questions in a category the user can click another category and answer those questions. After a user has finished all of the questions the user has the option to save their score by typing a username.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Back-End Development &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I started by working on the back-end of the project by running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails new PROJECT_backend --database=postgresql --api&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The line above creates a new rails project with PostgreSQL as the database. To deploy the backend of the application to Heroku the database needs to be PostgreSQL since SQLite is not supported. &lt;/p&gt;

&lt;p&gt;I created my models by running: &lt;br&gt;
&lt;code&gt;rails g model Category&lt;/code&gt;&lt;br&gt;
&lt;code&gt;rails g model Question&lt;/code&gt;&lt;br&gt;
&lt;code&gt;rails g model User&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A category has_many questions and a question belongs_to a category. The user model did not have any associations since I won't be authenticating a user.&lt;/p&gt;

&lt;p&gt;After creating the models, I ran the migrations, added model classes, and associations. I created the seed data and checked the associations using rails console. After verifying that the associations were correct I proceeded to create an api/v1 folder under controllers to namespace the routes. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M5vdkZlP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q27jv74ytm4u17zatzex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M5vdkZlP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q27jv74ytm4u17zatzex.png" alt="Rails Console showing associations" width="874" height="684"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I added the &lt;code&gt;gem 'rack-cors'&lt;/code&gt; to allow the backend to perform asynchronous requests. I added the &lt;code&gt;gem 'fast_jsonapi'&lt;/code&gt; and created the controllers. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails g controller api/v1/Category&lt;/code&gt;&lt;br&gt;
&lt;code&gt;rails g controller api/v1/Question&lt;/code&gt;&lt;br&gt;
&lt;code&gt;rails g controller api/v1/User&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I namespaced the routes to indicate their association to the first version of an API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XbKmPjzL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajbderxil2kz3jxaorjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XbKmPjzL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajbderxil2kz3jxaorjb.png" alt="Image description" width="384" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I verified that the routes were correct by running &lt;code&gt;rails routes&lt;/code&gt; and then verifying once again by going to &lt;code&gt;http://localhost:3000/rails/info/routes&lt;/code&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Front-End Development&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I began working on the front-end by creating a new repository for and adding an index.html file and a src file that would hold the index.js file. I then added a script tag for the index.js file in the index.html. I created an alert in the index.js file to ensure that the files were connected. I created individual files for questions, categories, and users in the src file and added the end points for each class at the top of the index.js file: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NewKagOe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qckn2kp91rzy0lurfqv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NewKagOe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qckn2kp91rzy0lurfqv5.png" alt="Image description" width="569" height="72"&gt;&lt;/a&gt;&lt;br&gt;
A POST request can be made if a user decides to save their score after completing the game. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
