Posts

Showing posts with the label ROR

One to Many Association

Image
Greetings Geeks, Let's  understand how to work with  one-to-many associations .   One-to-many associations are gonna be similar   to one-to-one associations,   but there are a few main differences that I wanna highlight.   First, one-to-many associations   are gonna be much more commonly used.   In a typical application, you'll rarely use one-to-one,   but you'll use one-to-many the most often.   Second, because we have one object related to many objects,   we're gonna use plural names.   That's both gonna be true when we define the association   and also when we call the methods on it. And third, the relationship   is going to return an array of objects back to us   instead of a single object.   And that just makes sense, right?   If we're going to have many records associated with it,   we're going to have to store those in an array   so that it can hold all of those records...

One to one association

Image
Welcome,  First, consider   when you might actually use a one-to-one association   because there are two main use cases.   The most common reason is for unique items   that a person or a thing can have only one of.   For example, an employee has_one : office   or a student has_one : id_card .   The ID card is unique.   It belongs only to this one student   and to no one else.   And that student is only allowed to have one ID card.   It's certainly possible to imagine a scenario   where an employee might have two offices. But by using a has_one relationship,   we're rejecting that possibility in our design.   We've made it a statement of fact   that each employee can have only one.   At the point that we want to allow employees   to have more than one,   we would need to revise our relationships to match. The second reason to use a one-to-one relationship   is to break up a sing...

Ruby Database Migration

Database Migration Greetings!!! This blog page will help you to play with the schema. First of all, make sure that you have everything setup. Let's see what is required MySQL path variable   Make sure that your environment variable is set for the MySQL bin folder. Following are the steps to setup environment variable: On the Windows desktop, right-click the  My Computer  icon, and select  Properties . Next , select the  Advanced  tab from the  System Properties  menu that appears, and click the  Environment Variables  button. Under  System Variables , select  Path , and then click the  Edit  button. The  Edit System Variable  dialogue should appear. Place your cursor at the end of the text appearing in the space marked  Variable Value . (Use the  End  key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path name ...

MVC Architechture

Image
Understanding MVC Architecture The Ruby On Rails Framework   uses an MVC Architecture.   It's a fundamental part of how the framework is structured   and it is designed to help us not repeat ourselves.   MVC is a fundamental aspect of rails,   which is important to understand right from the start.   M, V, and C.   The 'M' stand for  Model ,   the 'V' stands for  View ,   and the 'C' stands for  Controller .   The Model refers to the data objects that we use.  It's the object-oriented approach to design. Many things can be objects in our models   but the data in our Database   will be the most common type of object   that we'll put there.   The View is the presentation layer .   It's what the user sees and interacts with.   The web pages, the HTML, the CSS, the JavaScript.   The  Controller processes and response   to user events .   Such as clicking on links and...