<?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: DavidNNussbaum</title>
    <description>The latest articles on DEV Community by DavidNNussbaum (@davidnnussbaum).</description>
    <link>https://dev.to/davidnnussbaum</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%2F504060%2Fa22f4b00-3052-485c-8b16-7dd96e237cb3.jpeg</url>
      <title>DEV Community: DavidNNussbaum</title>
      <link>https://dev.to/davidnnussbaum</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davidnnussbaum"/>
    <language>en</language>
    <item>
      <title>React Or Angular – Which Is Better? It Depends.</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Sun, 06 Feb 2022 00:37:35 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/react-or-angular-which-is-better-it-depends-2pkb</link>
      <guid>https://dev.to/davidnnussbaum/react-or-angular-which-is-better-it-depends-2pkb</guid>
      <description>&lt;p&gt;React which was developed by Facebook is a JavaScript library that facilitates the creation of interactive user interfaces. It uses server-side rendering to provide a flexible, performance-oriented solution and is unidirectional. Angular was developed by Google and is a structural framework (as opposed to just being a library) for developing dynamic web apps. It is bidirectional.&lt;/p&gt;

&lt;p&gt;Many postings extoll the virtues of one system over another, yet as with most things in life one must evaluate the situation with a view of what the particular circumstances are. In the final analysis, one should not simply add the number of factors that favor React or Angular but also take into account the importance of each factor to you. &lt;/p&gt;

&lt;p&gt;If you don’t have time for a learning curve – React is better.&lt;br&gt;
If community support is important – Angular is better.&lt;br&gt;
If installation time cannot be lengthy – Angular is better.&lt;br&gt;
If flexibility is important – React is better.&lt;br&gt;
If you want simple updates – React is better.&lt;br&gt;
If you want to develop Native, hybrid, or web apps – React is better.&lt;br&gt;
If you want to develop Single Page Applications or mobile apps – Angular is better.&lt;br&gt;
If you want to develop native-rendered apps for Android and iOS devices – React is better.&lt;br&gt;
If you want to develop feature-rich, large-scale applications – Angular is better.&lt;br&gt;
If you don’t want to have to update the model state with every data change -Angular is better.&lt;br&gt;
If you want a single tool for testing and debugging – Angular is better.&lt;br&gt;
If you want faster documentation – React is better.&lt;br&gt;
If you prefer JavaScript – React is better.&lt;br&gt;
If you prefer TypeScript – Angular is better.&lt;br&gt;
If third party integration is important – React is better.&lt;br&gt;
If ease of moving from one view to another is important – Angular is better.&lt;br&gt;
If enhanced support for server side rendering is important – React is better.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>react</category>
      <category>angular</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Review Of Several Python Supervised Learning Classifiers With Some Of Their Advantages And Drawbacks</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Mon, 31 Jan 2022 01:23:05 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/a-review-of-several-python-supervised-learning-classifiers-with-some-of-their-advantages-and-drawbacks-1o8e</link>
      <guid>https://dev.to/davidnnussbaum/a-review-of-several-python-supervised-learning-classifiers-with-some-of-their-advantages-and-drawbacks-1o8e</guid>
      <description>&lt;p&gt;In the realm of Python supervised learning there are many classifiers that can be accessed utilizing the scikit-learn library. These are algorithms that are given training data which consists of a large portion of the data on hand. A certain percentage, many times around 20%, is saved as the test set.  The information that we want the model to determine is designated as the target. The model uses the features associated with each unit of the training set to determine the relationships between the features and the target. The model is then given the data from the test set which has the target removed and a determination is made as to how accurate the model is in predicting the target in the test set.&lt;/p&gt;

&lt;p&gt;We will review various classifiers with their pros and cons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;K-Nearest Neighbors&lt;/strong&gt; – The model studies which pieces of data are closest to each other. It is a simple approach but slows down as the data set becomes larger.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logistic Regression&lt;/strong&gt; – This model is good for determining an outcome. There are three types:&lt;br&gt;
1)  &lt;strong&gt;Binary Logistic Regression&lt;/strong&gt; – The model predicts whether something is or is not true – if an email is spam or not or if a tumor is malignant or not.&lt;br&gt;
2)  &lt;strong&gt;Multinomial Logistic Regression&lt;/strong&gt; – There are three or more categories without ordering. An example would be to determine which is the favorite activity, horseback riding, bowling, or swimming.&lt;br&gt;
3)  &lt;strong&gt;Ordinal Logistic Regression&lt;/strong&gt; – There are three or more items with ordering for example rating of baseball teams from 1-10.&lt;/p&gt;

&lt;p&gt;There is a decision boundary and the determination is made based on where the item appears relative to the decision boundary.&lt;/p&gt;

&lt;p&gt;A drawback would be that it is not used to classify items, for example to determine if a picture is of a horse, a cow, or a chicken.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decision Tree&lt;/strong&gt; – In this algorithm the goal is to create a model that predicts the value of a target variable in the test data by learning simple decision rules inferred from the training data features. The logic is transparent and can therefore be followed. &lt;/p&gt;

&lt;p&gt;Two of the downsides are that a person can create over-complex trees that do not generalize the data well. In addition, one can create biased trees if some classes dominate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Random Forest&lt;/strong&gt; – Here many decision trees are used, each working on a subset of the data. Their results are averaged in an attempt to obtain a more accurate result. &lt;/p&gt;

&lt;p&gt;Drawbacks include that the actual functioning is not transparent and for a large data set there is tremendous usage of memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support Vector Machine&lt;/strong&gt; – This model segregates the given dataset in the best possible way. The distance between the nearest points is known as the margin which is better if it is smaller. The objective is to select a hyperplane with the maximum possible margin between support vectors in the given dataset. Support vectors are the data points, which are closest to the hyperplane and will define the separating line better by calculating margins. The hyperplane is a decision plane which separates between a set of objects having different class memberships.&lt;/p&gt;

&lt;p&gt;A drawback would be that it is not suitable for large datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voting&lt;/strong&gt; – This model basically accumulates the results of multiple other models and makes a prediction based on one of two types:&lt;br&gt;
1)  &lt;strong&gt;Hard voting&lt;/strong&gt; – The votes of the various models are summed and the class with the most votes is predicted. &lt;br&gt;
2)  &lt;strong&gt;Soft voting&lt;/strong&gt; – The predicted probabilities from the various models are summed and the prediction is made based on the class label with the largest sum probability.&lt;/p&gt;

&lt;p&gt;A drawback is that multiple models have to be run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Naïve Bayes&lt;/strong&gt; – This algorithm goes on the assumption that the various features are not dependent one on another. It is used for classification and goes by probability. The class with the highest probability is considered to be the class to which the data point belongs. It is considered a fast algorithm.&lt;/p&gt;

&lt;p&gt;A drawback is that this algorithm presumes that all features are independent of each other which they rarely are, however despite this for binary classification there is a relatively high successful prediction rate. &lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>classifiers</category>
    </item>
    <item>
      <title>Creating A Hash Table</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Tue, 04 Jan 2022 20:01:05 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/creating-a-hash-table-50hl</link>
      <guid>https://dev.to/davidnnussbaum/creating-a-hash-table-50hl</guid>
      <description>&lt;p&gt;JavaScript includes Hash Tables which are a data structure that allow one to create a list of paired values. One is then able to retrieve a certain value by accessing the key for that value, which was previously placed into the table. Andrei Neagoie covered this in his Udemy course entitled “Master the Coding Interview: Data Structures + Algorithms.’&lt;/p&gt;

&lt;p&gt;First a class named “HashTable” is created with a constructor having a parameter of the size with the data consisting of a new array with the same size as a parameter. &lt;/p&gt;

&lt;p&gt;A private method (which theoretically should not be reachable outside of its class) called  “_hash” is created with a parameter of the key. The hash is initiated with a value of 0. An iterating variable of “i” is created which is not allowed to exceed the length of the key. A variable called “hash” is then created containing The “charCodeAt()” method which returns the Unicode of the character at a specified index in a string.  The data length is then invoked and the hash returned. &lt;/p&gt;

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

&lt;p&gt;We next need a method to add keys and values to the Hash Table. A method called “set” is created with its parameters being the key and value. A variable “address” is created which equals the “_hash” method. If there is no current address then an empty array is instituted. If there is a current address then the new key/value pair is added. &lt;/p&gt;

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

&lt;p&gt;The next step is to create a method which would allow one to retrieve information. One would do this by entering the key and then one could display either the key, the value, or both. A method called “get” is created.  In this method the variable “address” again equals the “_hash” method. A variable currentBucket is created equaling the address. As long as currentBucket exists, it is iterated over until the key equaling the desired key is located and in this case the value is returned (the key being at index 0 and the value at index 1). If the currentBucket does not exist then undefined is returned. &lt;/p&gt;

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

&lt;p&gt;Finally a method called “keys” is created that will produce an array of all the keys. It has no parameters. A variable called “keysArray” is created which is an empty array. The data is the iterated over with the keys being pushed one by one into the empty array and the array containing the keys is returned. &lt;/p&gt;

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

&lt;p&gt;The usage of this function entails using a variable to create a new instance of the class “HashTable” with the size as the argument.The methods within the function are then appended to the variable to obtain the desired results.  For the “set” method the key and value are the arguments and for the “get” method the key is the argument. The “keys” method has no arguments but don’t forget the (). An example is given below:&lt;/p&gt;

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

&lt;p&gt;Thank you for reading.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>hashtable</category>
      <category>programming</category>
    </item>
    <item>
      <title>Prepending, Inserting, and Deleting Nodes In A JavaScript Singly Linked List </title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Mon, 27 Dec 2021 17:51:32 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/prepending-inserting-and-deleting-nodes-in-a-javascript-singly-linked-list-pb</link>
      <guid>https://dev.to/davidnnussbaum/prepending-inserting-and-deleting-nodes-in-a-javascript-singly-linked-list-pb</guid>
      <description>&lt;p&gt;To view the code previously written you can look at the previous posting entitled “Building a Singly Linked List in JavaScript”. A modification is being made to the original code. Since new nodes will be added multiple times (as opposed to initially when it was only done once) we are first creating a new class called “Node” with a value and initially pointing to null. This is done so that the coding does not have to be repeated and only a new instance of this class needs to be created.&lt;/p&gt;

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

&lt;p&gt;In the prepend method, first a new instance of node is created with the value being supplied as the parameter. The previous head of the Linked List now becomes the node pointed to by the new node and the new node then becomes the head of the Linked List. The length is increased by one and the Linked List is returned.&lt;/p&gt;

&lt;p&gt;The methods to insert a new node in a certain spot and to delete a node at a particular spot both require finding that spot and both methods share this code. A separate method is therefore created to carry out this operation. The method is called here “proceedToIndex” and has as a parameter the index that we are looking for. A variable called “counter” is created with an initial value of 0. Utilizing a while loop, the node being iterated on is constantly moved forward and the counter is increased until the counter equals the index that was entered as an argument and then returns the node located at that index.&lt;/p&gt;

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

&lt;p&gt;The method to insert the new node can now be created. We first use an "if loop" to ensure that if the index number given is equal to or higher than the actual number of nodes then the append method is activated to add the value as a new tail for the Linked List. If the index argument is smaller than the number of nodes then the remainder of the insert method is activated. First a new instance of Node is instantiated. Next a variable “first” is created which utilizes the “proceedToIndex” method to locate the node which is at the point of insertion. The parameter is index-1 because the Linked Link index starts at 0 and therefore a submitted number of “4” would be at index”3” in the Linked List. The variable “holdingPointer” is what the previously identified node points to. What it points to is updated as the new node which then points to the node that was previously immediately after the node before the new node. The length of the Linked List is the increased by one. In summary, if the new node “N” is being inserted after index 5 containing node “P” that was originally followed at index 6 with node “F”, the pointer in node “P” (index 5) is changed from “F” and now points to “N” (which now at index 6) and the pointer of “N” now points to “F” (which is now at index 7).&lt;/p&gt;

&lt;p&gt;The method to delete a node is simpler. First, we proceed to the appropriate index utilizing the “proceedToIndex” method. The variable “deleteableNode” representing the node to be deleted is established as the node after the previously identified one. The pointer of the node previous to the node to be deleted is now changed to point to the node after the node to be deleted, thus eliminating the node between the two from the Linked List. The length of the Linked List is then decreased by one.&lt;/p&gt;

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

&lt;p&gt;As a simplification, a method is being created so that the linked list appears as an array in the terminal. First an empty array is created. The current node is started as the head and then each next node becomes the current node in turn and is pushed into the array until the last node is passed which means that the current node is now null. The loop ends at that point.&lt;/p&gt;

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

&lt;p&gt;Thank you for reading! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>linkedlist</category>
    </item>
    <item>
      <title>Using JavaScript To Compare Two Strings Containing Deleting Element(s) – Two Versions</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Thu, 23 Dec 2021 17:21:27 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/using-javascript-to-compare-two-strings-containing-deleting-elements-two-versions-4l24</link>
      <guid>https://dev.to/davidnnussbaum/using-javascript-to-compare-two-strings-containing-deleting-elements-two-versions-4l24</guid>
      <description>&lt;p&gt;There are always several ways to code a solution and an example of this will be shown here. One is presented with two strings to be compared and the program should yield “true” if they match and “false” if they don’t. These strings can contain one or more of the symbol “$”. Each “$” deletes in turn its preceding letter. The comparison of the strings should take this into consideration.&lt;/p&gt;

&lt;p&gt;In order to take Big O time consideration into account, “const” (the faster option) is used instead of “let”. Since the loops are not nested, we have O(n) instead of O(n^2).&lt;/p&gt;

&lt;p&gt;The beginning is the same for both versions. A variable compareStrings is created which represents a function that takes in 2 parameters. We first eliminate the simplest case so if the strings match as they are then the return is “true”. If not, then 2 new empty arrays are created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VERSION 1 CONTINUATION:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The letter “i” represents the index for the first argument and the string is iterated over. If the symbol “$” appears, then the last letter entered in the array is removed. If the item at that index is a letter, then it is added to the array. The same is done for the second argument except that the letter "j" is utilized. The arrays are then converted into strings and compared. If they are equivalent then ‘true” is returned, otherwise the return is “false”. &lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;VERSION 2 CONTINUATION:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A variable loopLength is created and Math.max() is used to determine which argument’s length is longer. This is the number that the “i” which is the letter representing the index to iterate over the strings must be less than to ensure that even the longer string is completely iterated over. For each string it is first determined that the string is not undefined. If it is not then if the symbol “$” appears, then the last letter entered in the array is removed. If the item at that index is a letter, then it is added to the array. The same is done for the second argument. The arrays are then converted to strings and compared utilizing a ternary operator. If they are equivalent then ‘true” is returned, otherwise the return is “false”. &lt;/p&gt;

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

&lt;p&gt;Please note that since “$” is eliminated, if that symbol appears at the beginning meaning that there were no letters to pop from the array, it will not change the “true” or “false” response.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Building a Singly Linked List in JavaScript</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Sun, 12 Dec 2021 17:38:06 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/building-a-singly-linked-list-in-javascript-3kfa</link>
      <guid>https://dev.to/davidnnussbaum/building-a-singly-linked-list-in-javascript-3kfa</guid>
      <description>&lt;p&gt;Linked Lists are a linear collection of data elements whose order is not given by their physical placement in memory. Instead, it is a collection of nodes each one pointing to the next one which together represent a sequence. Each node consists of a pointer to the next node and a value that it contains. This value could be any type of data type. A singly linked list is unidirectional. The first node is called the head and the last node is called the tail and it points to null. Linked Lists represent a time saving over arrays in that with an array after the previously set size is reached an area of double the size is established in memory. In addition, when inserting or deleting items anywhere but at the end, all of the indices from the insertion point and onward must be changed. Both of these steps are time consuming for an array. Linked lists have an advantage over hash tables in that linked lists are ordered. A disadvantage that Linked Lists have compared to arrays is that the data is scattered in different memory locations and takes up more memory due to the pointers. Another disadvantage is that without indices, the nodes must be accessed sequentially. &lt;/p&gt;

&lt;p&gt;In building the Linked List, it has nodes, the first one being the head and the last one being the tail. Each node has a value and a pointer which in the case of the tail points to null. We first create a class with a constructor that has a value as its parameter and has this.head containing a value which equals the argument value and the pointer (called “next”) equaling null since at the outset the head is also the tail. The length is initialized as 1.  In order to be able to add a node, the append method is created. This method creates a variable called newNode which represents the new node and has a value of the argument value and next (the pointer) with a value of null (since this is the new tail). The tail is now updated to be the new node, and the length of the Linked List is increased by 1.&lt;/p&gt;

&lt;p&gt;To demonstrate this, a new Linked List will be built with node values of 30, 18, and 22. If one wants to further build the Linked List, then it would involve additional methods which should be covered in a future posting.&lt;/p&gt;

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

&lt;p&gt;The results in the terminal are as follows: &lt;/p&gt;

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

&lt;p&gt;Thanks for reading! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>A Quick Guide To Setting Up a Rails Directory</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Sun, 05 Dec 2021 19:13:37 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/a-quick-guide-to-setting-up-a-rails-directory-55be</link>
      <guid>https://dev.to/davidnnussbaum/a-quick-guide-to-setting-up-a-rails-directory-55be</guid>
      <description>&lt;p&gt;First create a new repo on github.&lt;/p&gt;

&lt;h2&gt;
  
  
  In your terminal, cd to the directory in which you want the rails directory to reside. Please note the words &lt;strong&gt;directory&lt;/strong&gt;, &lt;strong&gt;file-name&lt;/strong&gt;, &lt;strong&gt;YourName&lt;/strong&gt;, &lt;strong&gt;ModelName&lt;/strong&gt;, and &lt;strong&gt;column_name&lt;/strong&gt; are being used as generic terms to be replaced with the actual names that you are using. 
&lt;/h2&gt;

&lt;p&gt;Now enter:&lt;br&gt;
*&lt;em&gt;~/directory$ rails new file-name  -T --database=postgresql --no-test-framework *&lt;/em&gt;&lt;br&gt;
Please note that if you do not enter -T --database=postgresql, to install PostgreSQL then the default database is SQLite.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you do not enter --no-test-framework then the default is to include the extra test files.
&lt;/h2&gt;

&lt;p&gt;Next cd to the created rails file:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory$ cd file-name&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The next steps will allow you to push your changes to github. Enter the following with everything after the word origin being a copy of the SSH from your github repo. &lt;/p&gt;

&lt;h2&gt;
  
  
  ~/directory/file-name$ git remote add origin &lt;a href="mailto:git@github.com"&gt;git@github.com&lt;/a&gt;:YourName/file-name.git
&lt;/h2&gt;

&lt;p&gt;Next enter:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$  git branch&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Followed by:&lt;br&gt;
&lt;strong&gt;~/directory/file-name$ git status&lt;/strong&gt;&lt;br&gt;
The following will appear in the terminal:&lt;br&gt;
On branch master&lt;/p&gt;

&lt;h2&gt;
  
  
  No commits yet
&lt;/h2&gt;

&lt;p&gt;Next add (the period after a space is part of the entry):&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git add .&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Followed by:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git commit -m "Setting up the file."&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Then enter:&lt;br&gt;
&lt;strong&gt;~/directory/file-name$ git status&lt;/strong&gt;&lt;br&gt;
The following will appear in the terminal:&lt;br&gt;
On branch master&lt;/p&gt;

&lt;h2&gt;
  
  
  nothing to commit, working tree clean
&lt;/h2&gt;

&lt;p&gt;Next enter:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git branch -M master&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Followed by:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git push -u origin master&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Next enter:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git pull origin master --allow-unrelated-histories&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Followed by:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ git push --set-upstream origin master&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you are installing PostgreSQL enter, otherwise skip this step:&lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;~/directory/file-name$ gem install pg  *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;No matter what your database is the next step is: &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ bundle install&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Followed by:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;~/directory/file-name$ rails db:create&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To set up each model enter:&lt;br&gt;
&lt;strong&gt;~/directory/file-name$ rails g model ModelName column_name:type  foreign_key:references&lt;/strong&gt;&lt;br&gt;
Please note that you can add in as many columns as are present for this model. The references term will create a column called whatever the foreign key is with _id attached.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>programming</category>
    </item>
    <item>
      <title> Tracking The Flow of Information in React.js</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Sun, 15 Aug 2021 22:55:31 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/tracking-the-flow-of-information-in-react-js-2589</link>
      <guid>https://dev.to/davidnnussbaum/tracking-the-flow-of-information-in-react-js-2589</guid>
      <description>&lt;p&gt;A major advantage of React is that it facilitates the overall process of writing components which can then in turn be reused. It can become challenging to track the flow of information from one component to another, especially when one wants to keep track of the props. Having a flow chart to be used as an available reference would allow a person to easily view the progression of information among the components. In this example, an actual React project will be utilized.&lt;/p&gt;

&lt;p&gt;One would start in the parent component (which many times is App.js) and look at the components that are rendered within it. These components probably have props which are included to pass down. Here is an example:&lt;/p&gt;

&lt;p&gt;src/componentsApp.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IWuo_5ox--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44iifwul4n905hctv3jv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IWuo_5ox--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44iifwul4n905hctv3jv.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Login, Signup, and Medications are rendered.  We therefore start with the following connections:&lt;br&gt;
App  → Login&lt;/p&gt;

&lt;p&gt;App → Signup&lt;/p&gt;

&lt;p&gt;App  → Medications&lt;/p&gt;

&lt;p&gt;src/components/Login.js &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ddwOxYyM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8si9rlhprebnieln3oev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ddwOxYyM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8si9rlhprebnieln3oev.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LoginForm is rendered. The flow chart is updated to the following.&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup&lt;/p&gt;

&lt;p&gt;App  → Medications&lt;/p&gt;

&lt;p&gt;LoginForm is opened and looking at the code reveals that it does not have any children so that line is complete. Any component without children are not shown in this post. We now go to Signup. When there are no children, (End) is entered to clarify that no component was left out of that progression.&lt;/p&gt;

&lt;p&gt;src/components/Signup.js &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EHoRX_VA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk3omrnkiuk01crfepru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EHoRX_VA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk3omrnkiuk01crfepru.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SignupForm is rendered and therefore added to the list.&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications&lt;/p&gt;

&lt;p&gt;SignupForm does not have any children so that line is complete. We now go to back to Medications. For the remainder of this posting, the logic will be continued. A progression will be followed and when a new progression is advanced, that will be an indication that the previous progression's last component had no children. If a branching occurs, every component up to that branching will be repeated. &lt;/p&gt;

&lt;p&gt;src/components/Medications.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j1zLb9nf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by9j14pvz6kqmuepar6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j1zLb9nf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/by9j14pvz6kqmuepar6y.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList&lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication&lt;/p&gt;

&lt;p&gt;src/lists/MedicationList.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XHF-S9ZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33dunl3p65klgthy6n89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XHF-S9ZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33dunl3p65klgthy6n89.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → Medication(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList&lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication&lt;/p&gt;

&lt;p&gt;src/lists/ComplicationList.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vliubOpl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vwzztkm33mgxirvcmuz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vliubOpl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vwzztkm33mgxirvcmuz.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → Medication(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → Complication&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → CreateComplication&lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication&lt;/p&gt;

&lt;p&gt;src/components/Complication.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3-1_XbQ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4j2qghnms2hiupjlj95o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3-1_XbQ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4j2qghnms2hiupjlj95o.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → Medication(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → Complication → EditComplicationForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → CreateComplication &lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication&lt;/p&gt;

&lt;p&gt;src/components/CreateComplication.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qsnBfVNy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk0ew9hbjqln2a3b6o1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qsnBfVNy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk0ew9hbjqln2a3b6o1v.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → Medication(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → Complication → EditComplicationForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → CreateComplication  → ComplicationForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication&lt;/p&gt;

&lt;p&gt;src/components/CreateMedication.js&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BHyUC7E7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xto97gvo3veh62g45a44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BHyUC7E7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xto97gvo3veh62g45a44.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;App  → Login → LoginForm(End)&lt;/p&gt;

&lt;p&gt;App → Signup → SignupForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → Medication(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → Complication → EditComplicationForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → MedicationList → ComplicationList → CreateComplication  → ComplicationForm(End)&lt;/p&gt;

&lt;p&gt;App  → Medications → CreateMedication → MedicationForm(End)&lt;/p&gt;

&lt;p&gt;There is now a complete list of the progression of information which can be referenced during the building or usage of React.js programming.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Javascript Front End Coordination with Ruby Back End For User Sign Up and Log On</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Thu, 10 Jun 2021 13:52:31 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/javascript-front-end-coordination-with-ruby-back-end-for-user-sign-up-and-log-on-2ogc</link>
      <guid>https://dev.to/davidnnussbaum/javascript-front-end-coordination-with-ruby-back-end-for-user-sign-up-and-log-on-2ogc</guid>
      <description>&lt;p&gt;This posting will go through the steps that allow a Javascript front end to fetch user information from a Ruby API back end. Please note that JWT authentication is not being included and certainly should be if there is sensitive information being stored on the site. This particular site allows a user to sign in or to log on and then select from a list of doctors or add a doctor. The user can then add, edit, or delete their reviews, but view other peoples’ reviews without the ability to edit or delete them. We will start by setting up the Ruby API back end.&lt;/p&gt;

&lt;p&gt;The first step is to activate gem 'bcrypt' and gem 'jsonapi-serializer' in the Gemfile and utilize bundle install.&lt;/p&gt;

&lt;p&gt;The next step is to set up the model using rails g model User. In this case first_name, email, and password_digest are the attributes.&lt;/p&gt;

&lt;p&gt;Here is a sample schema:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9IqT9MIk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lg792f3sp1v6cwl9m3yy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9IqT9MIk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lg792f3sp1v6cwl9m3yy.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you will notice, password_digest is the appropriate wording for the users table. Next, the user.rb model must be modified to reflect the flow of information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ek5YUtjd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90wuuutma0rzvo8ny36t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ek5YUtjd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90wuuutma0rzvo8ny36t.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The relationships have been set up, has_secure_password is present and the validations are included. The user_serializer.rb will now be viewed.&lt;/p&gt;

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

&lt;p&gt;The serializer determines which attributes will be transmitted to the front end. The relationship between the user and the doctors they have commented on is established. One can see how the UserSerializer is utilized to help package the json data. Error messages have been created. The jsonapi-serializer gem that is being utilized forces us to include the word ”object” in the doctors method.&lt;/p&gt;

&lt;p&gt;The users_controller.rb file is examined next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YClVDfMl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yirspzpy5ocslcjelwzo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YClVDfMl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yirspzpy5ocslcjelwzo.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DzoMf_Tb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fmhb1oc7xyh1vo0pllav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DzoMf_Tb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fmhb1oc7xyh1vo0pllav.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FG9Y55gg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kypmleqw3vxw3lozno1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FG9Y55gg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kypmleqw3vxw3lozno1h.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike pure rails, here in the API it is JSON that is rendered and the UserSerializer class that was previously created is utilized. &lt;/p&gt;

&lt;p&gt;In the front end there are the getter functions associated with the user button as well as the log on, sign in and sign out getter functions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ANKDQ7Vx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvqeensse77kt2lmikz0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ANKDQ7Vx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvqeensse77kt2lmikz0.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cr8H8L9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdl259nuwgirn4wdt2lp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cr8H8L9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdl259nuwgirn4wdt2lp.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next the user model is created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VkMrRd5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0v5e4ikfjq9vzxedm7qw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VkMrRd5l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0v5e4ikfjq9vzxedm7qw.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yadRKJHu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed62xfc381f1135bxqt9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yadRKJHu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed62xfc381f1135bxqt9.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DQdEggjc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqc00prfkw5sed26w1d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DQdEggjc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqc00prfkw5sed26w1d6.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3hG1APKi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdtz4yix2bh11lxyx96v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3hG1APKi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdtz4yix2bh11lxyx96v.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The form allows for the appropriate information to be entered and &lt;br&gt;
 input type="password" is used so that the password is hidden as it is entered. The constructor does not include the password because we don’t want it to appear in the front end. &lt;/p&gt;

&lt;p&gt;The next file to look at is userApi.js.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l-TLoym1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ag03khpkx5n4h7712xfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l-TLoym1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ag03khpkx5n4h7712xfi.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5mkOUZRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2q96pakfy4ffy7e14wpt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5mkOUZRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2q96pakfy4ffy7e14wpt.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2yrO5LyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls1mqjbg06fvc1ok7be3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2yrO5LyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls1mqjbg06fvc1ok7be3.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that localStorage is used to hold the user’s information in the front end.&lt;/p&gt;

&lt;p&gt;Once these steps have been completed, you should be ready to have a user sign in or log on through the front end.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Rails Coding to Allow Log In Via Either Google or Facebook – A Step By Step Guide.</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Fri, 16 Apr 2021 21:08:30 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/rails-coding-to-allow-log-in-via-either-google-or-facebook-a-step-by-step-guide-2h35</link>
      <guid>https://dev.to/davidnnussbaum/rails-coding-to-allow-log-in-via-either-google-or-facebook-a-step-by-step-guide-2h35</guid>
      <description>&lt;p&gt;The setting up of coding to allow a user to log in via Google or Facebook is a little more complicated due to differences in their structure. &lt;/p&gt;

&lt;p&gt;The first step is to set up an account with the two sites. The following blog gives guidance regarding signing up with Google: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@amoschoo/google-oauth-for-ruby-on-rails-129ce7196f35"&gt;https://medium.com/@amoschoo/google-oauth-for-ruby-on-rails-129ce7196f35&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The blog giving guidance for signing up with Facebook is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/nkemjiks/implementing-facebook-authentication-with-devise-for-your-rails-6-app-1p3b"&gt;https://dev.to/nkemjiks/implementing-facebook-authentication-with-devise-for-your-rails-6-app-1p3b&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These two blogs give full instructions regarding the setting up of Google and Facebook developer accounts respectively. These should be followed. The ID and secret are the two pieces of information that you will need to use in your code. The blogs also explain how to set up the rails code for the use of either one but there are some minor changes necessary in order for there to be the option of using either Google or Facebook. That code is what will be discussed here.&lt;/p&gt;

&lt;p&gt;Be sure to have ‘uid’, ‘image’, and ‘provider’ columns in your users table. If not, use a migration to add them.&lt;/p&gt;

&lt;p&gt;When a screenshot is shown, the code regarding Omniauth is the only code that needs to be utilized.&lt;/p&gt;

&lt;p&gt;The next step is to add the omniauth related gems in the gemfile and use bundle install.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pcFsrXcl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7is2ncb8cd5qrpaiwe0c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pcFsrXcl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7is2ncb8cd5qrpaiwe0c.png" alt="Gemfile - pharmacy-medications-tracker [WSL_ Ubuntu] - Visual Studio Code 4_18_2021 8_34_08 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next Add the middleware to the project in config/initializers/omniauth.rb.&lt;/p&gt;

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

&lt;p&gt;The next step is to add the following routes in config/routes.rb&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dPi6_n6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rjy5z7sbosp6s7uk4de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dPi6_n6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rjy5z7sbosp6s7uk4de.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set up a controllers/omniauth_controller.rb file as follows:&lt;/p&gt;

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

&lt;p&gt;The view allowing for usage of Google and Facebook would be set up as follows:&lt;/p&gt;

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

&lt;p&gt;In config/routes.rb the following route would be used. In place of ‘social_media’, put in whichever view contains the link to Google and Facebook:&lt;/p&gt;

&lt;p&gt;post '/sessions/social_media' =&amp;gt; 'sessions#social_media'&lt;/p&gt;

&lt;p&gt;Create a .env file. It is VERY IMPORTANT that you add this file to your .gitignore file so that the codes are not pushed to your github repository and viewed publicly, and set it up as follows, utilizing the ID and secret that you received from the Google and Facebook sites in place of the words ENTER YOUR CODE HERE.&lt;/p&gt;

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

&lt;p&gt;Now you should be ready to allow users to log in with either Facebook or Google.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Being RESTful Is Not Always Best For The User</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Mon, 15 Feb 2021 01:16:31 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/being-restful-is-not-always-best-for-the-user-13p0</link>
      <guid>https://dev.to/davidnnussbaum/being-restful-is-not-always-best-for-the-user-13p0</guid>
      <description>&lt;p&gt;The RESTful convention has been invaluable regarding creating a consistency in the internet allowing for improved communication. However, as with most things in life, there are exceptions. My project involved having a page on which people can enter their medical histories and subjective reports. It would not be convenient for the user to enter part of the information on one page and then to proceed to the next page. This is separate from notes which a person may or may not make use of and therefore is appropriate to put on a separate page. &lt;/p&gt;

&lt;p&gt;This is the page being discussed:&lt;/p&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       Medical Information Notepad
       Medical Information For Peter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;General History:&lt;br&gt;
Medical Conditions:&lt;br&gt;
Medications:&lt;br&gt;
Allergies:&lt;br&gt;
Current Treatments:&lt;br&gt;
Surgeries:&lt;br&gt;
Immunizations With Dates:&lt;br&gt;
The Current Problem:&lt;br&gt;
Location of the Problem:&lt;br&gt;
Any Observed Changes:&lt;br&gt;
What You Are Feeling:&lt;br&gt;
What Is The Level Of Discomfort On A Scale Of 1 To 10:&lt;br&gt;
How Long This Has Been Going On:&lt;br&gt;
Press Here To Enter The Above Information:&lt;br&gt;
Press Here To Logout Without Saving The Information:&lt;/p&gt;




&lt;p&gt;The issue with this arrangement regarding the history and subjective areas is that they come from two separate tables. Therefore, the name on the route cannot be RESTful and simply use the name of the table since we have two tables represented on the page. &lt;br&gt;
The schema is as follows:&lt;/p&gt;




&lt;p&gt;create_table "comments", force: :cascade do |t|&lt;br&gt;
    t.text    "identifier"&lt;br&gt;
    t.text    "note"&lt;br&gt;
    t.text    "items_to_discuss"&lt;br&gt;
    t.text    "questions"&lt;br&gt;
    t.integer "patient_id"&lt;br&gt;
  end&lt;/p&gt;

&lt;p&gt;create_table "histories", force: :cascade do |t|&lt;br&gt;
    t.text    "diagnoses"&lt;br&gt;
    t.text    "medications"&lt;br&gt;
    t.text    "allergies"&lt;br&gt;
    t.text    "current_treatments"&lt;br&gt;
    t.text    "surgeries"&lt;br&gt;
    t.text    "immunizations_with_dates"&lt;br&gt;
    t.integer "patient_id"&lt;br&gt;
  end&lt;/p&gt;

&lt;p&gt;create_table "patients", force: :cascade do |t|&lt;br&gt;
    t.string "username"&lt;br&gt;
    t.string "password_digest"&lt;br&gt;
  end&lt;/p&gt;

&lt;p&gt;create_table "subjectives", force: :cascade do |t|&lt;br&gt;
    t.text    "location"&lt;br&gt;
    t.text    "observed_changes"&lt;br&gt;
    t.text    "sensation_changes"&lt;br&gt;
    t.string  "scale_1_to_10"&lt;br&gt;
    t.text    "length_of_time"&lt;br&gt;
    t.integer "patient_id"&lt;br&gt;
  end&lt;/p&gt;

&lt;h2&gt;
  
  
  end
&lt;/h2&gt;

&lt;p&gt;This is the code for the page being discussed. As you can see, the two tables have their respective information entered separately even though two tables are being updated:&lt;/p&gt;




&lt;h1 class="text-center"&gt;&lt;span class="border border-3"&gt;Medical Information Notepad&lt;/span&gt;&lt;/h1&gt;

&lt;h1 class="text-center"&gt;&lt;span class="border border-3"&gt;Medical Information For &lt;/span&gt;&lt;/h1&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h3&amp;gt;&amp;lt;u&amp;gt;General History:&amp;lt;/u&amp;gt;&amp;lt;/h3&amp;gt;
Medical Conditions: &amp;lt;br&amp;gt; 
Medications: &amp;lt;br&amp;gt;
Allergies: &amp;lt;br&amp;gt;
Current Treatments: &amp;lt;br&amp;gt;
Surgeries: &amp;lt;br&amp;gt;
Immunizations With Dates: &amp;lt;br&amp;gt;

&amp;lt;h3&amp;gt;&amp;lt;u&amp;gt;The Current Problem:&amp;lt;/u&amp;gt;&amp;lt;/h3&amp;gt;
Location of the Problem:&amp;lt;br&amp;gt;
Any Observed Changes: &amp;lt;br&amp;gt;
What You Are Feeling: &amp;lt;br&amp;gt;
What Is The Level Of Discomfort On A Scale Of 1 To 10: &amp;lt;br&amp;gt;
How Long This Has Been Going On:&amp;lt;br&amp;gt;
&amp;lt;h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;u&gt;Press Here To Enter The Above Information:&lt;/u&gt; &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;h3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;u&gt;Press Here To Logout Without Saving The Information:&lt;/u&gt; &lt;/p&gt;

&lt;p&gt;Finally, the following code allows for the saving of information for both sections from the same page:&lt;/p&gt;

&lt;p&gt;post '/patients/:id/info' do&lt;br&gt;
        redirect_if_not_logged_in&lt;br&gt;
        patient = Patient.find(session["patient_id"])&lt;br&gt;
        history = History.new(:diagnoses =&amp;gt; params[:histories][:diagnoses])&lt;br&gt;
        history.medications = params[:histories][:medications]&lt;br&gt;
        history.allergies = params[:histories][:allergies]&lt;br&gt;
        history.current_treatments = params[:histories][:current_treatments]&lt;br&gt;
        history.surgeries = params[:histories][:surgeries]&lt;br&gt;
        history.immunizations_with_dates = params[:histories][:immunizations_with_dates]&lt;br&gt;
        history.patient_id = patient.id&lt;br&gt;
        history.save&lt;br&gt;
        subjective = Subjective.create(:location =&amp;gt; params[:subjectives][:location])&lt;br&gt;
        subjective.observed_changes = params[:subjectives][:observed_changes]&lt;br&gt;
        subjective.sensation_changes = params[:subjectives][:sensation_changes]&lt;br&gt;
        subjective.scale_1_to_10 = params[:subjectives][:scale_1_to_10]&lt;br&gt;
        subjective.length_of_time = params[:subjectives][:length_of_time]&lt;br&gt;
        subjective.patient_id = patient.id&lt;br&gt;
        subjective.save&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    redirect 'patients/:id/info'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;As is evident from the above code, the route ends with /info which is not a RESTful term as /show would be. However, it does convey the meaning of what is presented on the page.&lt;/p&gt;

&lt;p&gt;In conclusion, RESTful convention should indeed be used as frequently as possible. This presentation gives an example where being non-RESTful can be justified.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>sinatra</category>
      <category>rest</category>
    </item>
    <item>
      <title>The examination of a JSON document utilizing Ruby: A 
     Step-by-Step Guide</title>
      <dc:creator>DavidNNussbaum</dc:creator>
      <pubDate>Mon, 14 Dec 2020 00:07:43 +0000</pubDate>
      <link>https://dev.to/davidnnussbaum/the-examination-of-a-json-document-utilizing-ruby-a-step-by-step-guide-2l3m</link>
      <guid>https://dev.to/davidnnussbaum/the-examination-of-a-json-document-utilizing-ruby-a-step-by-step-guide-2l3m</guid>
      <description>&lt;p&gt;A person could have learned how to work with nested hashes and yet still find a JSON file to be overwhelming. A JSON file does not only contain multiple layers of nested hashes but can also contain arrays nested sporadically among the hashes. The following are the steps that can be taken to examine the JSON document in an organized manner.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;           Step 1: Open your file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this overview an API to a JSON file will be utilized so that the reader can code along before moving on to a different JSON file. Obviously, the manner in which a file is opened will be determined by the exact location of the file. The code of binding.pry has been inserted so that the file can be examined in the terminal utilizing pry. Don’t forget to call the method in the file after creating it:&lt;/p&gt;

&lt;p&gt;require 'net/http'&lt;br&gt;
require 'open-uri'&lt;br&gt;
require 'json'&lt;br&gt;
require 'pry'&lt;/p&gt;

&lt;p&gt;URL = "&lt;a href="https://health.gov/myhealthfinder/api/v3/topicsearch.json?lang=en"&gt;https://health.gov/myhealthfinder/api/v3/topicsearch.json?lang=en&lt;/a&gt;"&lt;/p&gt;

&lt;p&gt;def get_info&lt;br&gt;
    uri = URI.parse(URL)&lt;br&gt;
    response = Net::HTTP.get_response(uri)&lt;br&gt;
    response.body&lt;/p&gt;

&lt;p&gt;end&lt;/p&gt;

&lt;p&gt;file = get_info&lt;br&gt;
binding.pry&lt;/p&gt;

&lt;p&gt;The following will appear in your terminal after running the file:&lt;/p&gt;

&lt;p&gt;david@LT000568:~/projects/health-information-site$ ruby lib/test.rb&lt;br&gt;
/home/david/.rvm/gems/ruby-2.6.1/gems/pry-0.13.1/lib/pry/editor.rb:19: warning: Insecure world writable dir /mnt/c in PATH, mode 040777&lt;/p&gt;

&lt;p&gt;From: /home/david/projects/health-information-site/lib/test.rb:20 :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;15:   
16:   end
17:  
18: 
19: file = get_info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;=&amp;gt; 20: binding.pry&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Step 2: Determine the length of the file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note that all entries from now on are being done in the terminal which is open to pry. Remember that if necessary, the letter q should be entered to be ready for the next entry. file.length gives us the size of the file.&lt;/p&gt;

&lt;p&gt;[1] pry(main)&amp;gt; file.length&lt;br&gt;
=&amp;gt; 1332586&lt;br&gt;
[2] pry(main)&amp;gt; &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Step 3: Parse the file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;One can examine more of the file by pressing on the down arrow as many times as one wants so examine as much of the file as is desired.&lt;br&gt;&lt;br&gt;
[2] pry(main)&amp;gt; data = JSON.parse(file)&lt;br&gt;
=&amp;gt; {"Result"=&amp;gt;&lt;br&gt;
  {"Error"=&amp;gt;"False",&lt;br&gt;
   "Total"=&amp;gt;98,&lt;br&gt;
   "Query"=&amp;gt;&lt;br&gt;
    {"ApiVersion"=&amp;gt;"3",&lt;br&gt;
     "ApiType"=&amp;gt;"topicsearch",&lt;br&gt;
     "TopicId"=&amp;gt;nil,&lt;br&gt;
     "ToolId"=&amp;gt;nil,&lt;br&gt;
     "CategoryId"=&amp;gt;nil,&lt;br&gt;
     "PopulationId"=&amp;gt;nil,&lt;br&gt;
     "Keyword"=&amp;gt;nil,&lt;br&gt;
     "Who"=&amp;gt;nil,&lt;br&gt;
     "Age"=&amp;gt;nil,&lt;br&gt;
     "Sex"=&amp;gt;nil,&lt;br&gt;
     "Pregnant"=&amp;gt;nil,&lt;br&gt;
     "TobaccoUse"=&amp;gt;nil,&lt;br&gt;
     "SexuallyActive"=&amp;gt;nil,&lt;br&gt;
     "Category"=&amp;gt;nil,&lt;br&gt;
     "Lang"=&amp;gt;"en",&lt;br&gt;
     "Type"=&amp;gt;nil,&lt;br&gt;
     "ReturnType"=&amp;gt;"json",&lt;br&gt;
     "Callback"=&amp;gt;nil,&lt;br&gt;
[3] pry(main)&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Step 4: Determine the type of the overall file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We will now use the .class method to confirm the type of the overall file. It is important to note that the “file” variable which is before the parsing is a string while the “data” variable which is after the parsing and which is what we are working with is a hash.&lt;/p&gt;

&lt;p&gt;[3] pry(main)&amp;gt; data.class&lt;br&gt;
=&amp;gt; Hash&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        Step 5: Since this is a hash, use the .keys method 
                  to find the first one.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This step could really be skipped since the first key was revealed in step 3. It is just being mentioned because it is a simple starting point for what can be an overwhelming amount of data.&lt;/p&gt;

&lt;p&gt;[4] pry(main)&amp;gt; data.keys&lt;br&gt;
=&amp;gt; ["Result"]&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        Step 6: Scroll down to find where the desired 
                 information is located.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here entering “data”, one can scroll using the down arrow to the first line of desired information. In this case it was "Keep Your Heart Healthy".&lt;/p&gt;

&lt;p&gt;[5] pry(main)&amp;gt; data&lt;br&gt;
=&amp;gt; {"Result"=&amp;gt;&lt;br&gt;
  {"Error"=&amp;gt;"False",&lt;br&gt;
   "Total"=&amp;gt;98,&lt;br&gt;
   "Query"=&amp;gt;&lt;br&gt;
    {"ApiVersion"=&amp;gt;"3",&lt;br&gt;
     "ApiType"=&amp;gt;"topicsearch",&lt;br&gt;
     "TopicId"=&amp;gt;nil,&lt;br&gt;
     "ToolId"=&amp;gt;nil,&lt;br&gt;
     "CategoryId"=&amp;gt;nil,&lt;br&gt;
     "PopulationId"=&amp;gt;nil,&lt;br&gt;
     "Keyword"=&amp;gt;nil,&lt;br&gt;
     "Who"=&amp;gt;nil,&lt;br&gt;
     "Age"=&amp;gt;nil,&lt;br&gt;
     "Sex"=&amp;gt;nil,&lt;br&gt;
     "Pregnant"=&amp;gt;nil,&lt;br&gt;
     "TobaccoUse"=&amp;gt;nil,&lt;br&gt;
     "SexuallyActive"=&amp;gt;nil,&lt;br&gt;
     "Category"=&amp;gt;nil,&lt;br&gt;
     "Lang"=&amp;gt;"en",&lt;br&gt;
     "Type"=&amp;gt;nil,&lt;br&gt;
     "ReturnType"=&amp;gt;"json",&lt;br&gt;
     "Callback"=&amp;gt;nil,&lt;br&gt;
     "HealthfinderPage"=&amp;gt;nil,&lt;br&gt;
     "APiType"=&amp;gt;"topicsearch"},&lt;br&gt;
   "Language"=&amp;gt;"English",&lt;br&gt;
   "Resources"=&amp;gt;&lt;br&gt;
    {"Resource"=&amp;gt;&lt;br&gt;
      [{"Type"=&amp;gt;"Topic",&lt;br&gt;
        "Id"=&amp;gt;"25",&lt;br&gt;
        "Title"=&amp;gt;"Keep Your Heart Healthy",&lt;br&gt;
        "TranslationId"=&amp;gt;"25",&lt;br&gt;
[6] pry(main)&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Step 7: Start listing the keys necessary to reach the 
                   information. 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;One can see that there is a first key “Result” and that the desired line is arrived at by going to the key called “Resources” followed by the key called “Resource.” We can now consecutively enter a key and using the .keys method choose which of its contained keys we want to use. Note that the "Resources" key only has one key following it and that is "Resource". When we encounter a non-hash such as an array, the .keys method will generate a NoMethodError.  &lt;/p&gt;

&lt;p&gt;[6] pry(main)&amp;gt; data["Result"].keys&lt;br&gt;
=&amp;gt; ["Error", "Total", "Query", "Language", "Resources"]&lt;br&gt;
[7] pry(main)&amp;gt; data["Result"]["Resources"].keys&lt;br&gt;
=&amp;gt; ["Resource"]&lt;br&gt;
[8] pry(main)&amp;gt; data["Result"]["Resources"]["Resource"].keys&lt;br&gt;
NoMethodError: undefined method `keys' for #&lt;a&gt;Array:0x00007fffc58bdcc0&lt;/a&gt;&lt;br&gt;
[9] pry(main)&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          Step 8: At the array, use indexing to find the 
                     desired information.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As we saw in step 6, the desired line is in the first hash within the array so this would be index 0. We will now examine the keys of that first hash in the array.&lt;br&gt;
[9] pry(main)&amp;gt; data["Result"]["Resources"]["Resource"][0].keys&lt;br&gt;
=&amp;gt; ["Type",&lt;br&gt;
 "Id",&lt;br&gt;
 "Title",&lt;br&gt;
 "TranslationId",&lt;br&gt;
 "TranslationTitle",&lt;br&gt;
 "Categories",&lt;br&gt;
 "Populations",&lt;br&gt;
 "MyHFTitle",&lt;br&gt;
 "MyHFDescription",&lt;br&gt;
 "MyHFCategory",&lt;br&gt;
 "MyHFCategoryHeading",&lt;br&gt;
 "LastUpdate",&lt;br&gt;
 "ImageUrl",&lt;br&gt;
 "ImageAlt",&lt;br&gt;
 "AccessibleVersion",&lt;br&gt;
 "RelatedItems",&lt;br&gt;
 "Sections",&lt;br&gt;
 "MoreInfoItems",&lt;br&gt;
 "HealthfinderLogo",&lt;br&gt;
 "HealthfinderUrl"]&lt;br&gt;
[10] pry(main)&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Step 9: Arriving at the desired information.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As seen in step 6, the desired line is the value for the “Title” key, so using it will allow us to arrive at the desired line.&lt;/p&gt;

&lt;p&gt;[10] pry(main)&amp;gt; data["Result"]["Resources"]["Resource"][0]["Title"]&lt;br&gt;
=&amp;gt; "Keep Your Heart Healthy"&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         Step 10: Continue in the same manner until all 
                 information is obtained.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Just continue repeating the above steps until you have collected all the desired information. In my case the next desired information was not near the first piece, so it took several keys and indices to arrive at it.&lt;/p&gt;

&lt;p&gt;[11] pry(main)&amp;gt;data["Result"]["Resources"]["Resource"][1]["Sections"]&lt;br&gt;
["section"][0]["Title"]&lt;br&gt;
=&amp;gt; "The Basics: Overview"&lt;br&gt;
[12] pry(main)&amp;gt;&lt;/p&gt;

&lt;p&gt;I hope that you found this posting to be helpful. Please let me know if you have any comments.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>json</category>
    </item>
  </channel>
</rss>
