Above I have created a class named Activity that is defined but nothing is in it yet. The first thing we need to do inside a class is to create a constructor function.
A constructor is a function that constructs an instance of a class which is called an object. In the future, if we want to create a new activity the constructor function will be responsible for creating that new activity object based on this class. …
Switch statements are very similar to if-else and else-if statement. However a switch statement is what programmers use when there is a lot of data that they want to check for.
The switch statement is evaluated once. The value of the statement is compared with each value of the each case. Once the statement is matched the code will be executed. However, if there is no match the default code will be executed.
In the example below we’ll ask a user for their name. For the switch statement we’ll put the name inside of the parentheses. …
.The fetch function is a function that allows you to fetch stuff. Anything from data to images from different sources and different places.
Theres this idea in web programming of making an HTTP request. You can make a GET request and POST request. In the blog I will show you both. …
The example below shows there is a condition followed by a question mark. If it is true it will return the first expression but if it is false it will return the second expression. The two expressions are separated by a colon.
condition ? one : two
Below I will show you an example with an if…
Below are a few examples:
I’m going to start by declaring a function using a function keyword. Then we have to name the function…
The filter() method returns an array that contains elements of a parent array that match the set test. The function containing the test is passed as the arguments to the filter method. The filter method returns true or false. If its true its in the new array and if it is false it is not in the new array. The great thing is that it doesn’t change the underlying object that you are filtering over.
An array of 3 items will be returned with less than or equal to 13.
console.log(students) returns all the students
Omniauth is a library that standardizes authentication for web applications. It allows you to add different sign-in methods with ease. Sign-ins are known as strategies. A strategy can be Twitter via OAuth 2 protocol or it could be LDAP Omniauth strategies are usually released as gems but you can also write your own if the gem doesn't exist for the authentication system that is being implemented.
There are all kinds of different gems out there. You just need to find one that would work with your application. There are usually instructions within the github.
To add the gem to your…
What is API?
API stands for Application Program Interface. There are all kinds of API. API’s are everywhere from computers, smartphones and even refrigerators. Specifically we will be talking about web API’s. It is essentially a contract provided by one piece of software to another piece of software that usually consists of a structured request and response.
One of the best examples of an analogy is restaurant. Think of yourself sitting at a table at a restaurant. You are one piece of software, such as a web application on the client side. The kitchen is the server or the service…
In any application you will find the following three fundamental parts:
MVC is short for models, views and controllers. MVC is a software design pattern/software pattern methodology. The main objective is to promote code usability and implement separation of concerns. The MVC model calls for the division of a software or application into three main components: models, views and controllers.
The model component contains the brains of the application. It creates separation of concern. …
I recently started applying for positions in the software engineering field. I also just started a new Rails project. I figured it would be a great opportunity to review everything I learned once again.
I decided to create Notes 2.0. It is an application that allows a user to create a notebook that they can share amongst their classmates. The classmates will also have the opportunity to leave notes. These notebooks will also be organized by categories.
I started off by creating the database and models.
The first relationship is known as belongs_to which is a singular naming convention that…