Posts

Showing posts from March, 2017

ActiveRecords and ActiveRelation

Image
Good to see you, Geek!!! This blog page will help you to understand ActiveRecord and ActiveRelation. ActiveRecord and ActiveRelation are part of the Rails framework that's going to power your models. So before you begin coding on your models get a big picture understanding of how they work.  Active Record Active record, when it's written all lowercase as two separate words refer to a commonly used design pattern for working with relational databases. It's not Rail specific. You could use the active record pattern in any programming language. It's an approach to designing object-oriented software.  ActiveRecord, when it's written as one word with a capital A and R, refers to the Rails implementation of the active record pattern. Often you can use the terms interchangeably but it's helpful to understand the context and to know the difference. The ActiveRecord design pattern allows you to retrieve database data as objects. And then to wor...

How to solve migration issues with rails

Greetings friends!!! Migrations make managing your database schema easy, however, problems often occur when we're running our migrations and run into a bug in our migration code. It can leave your migrations in a broken state where you can't migrate up and you can't migrate down. It's important to learn how this happens and how to resolve these problems when they occur. Use rails db:migrate version 0  to migrate to 0 level. STEPS to recover migrations issue: Make a note of migration issue. Try to resolve it manually by changing migration file. Perform migration to version 0. This will rollback all migrations. Comment all above code inside migration having an issue. Let's say for example if your line # 5 is causing an issue comment your code till line #4. Run rails db:migrate again  Verify that it shows success and double check with the database too, If it showing migration error perform step 1 to 5 till it shows the success. Uncomment your code and yo...

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...

Understanding Ruby On Rails

Introduction to Ruby on Rails Greetings Geeks!!! Ruby on Rails is made up of two parts.   Ruby and Rails.   And it's going to be important to understand the difference   and keep them straight in your head.   Ruby is an object-oriented programming language   created in 1995 by Yukihiro Matsumoto,   who often goes by the nickname Matz.   Ruby can be used for many purposes,   not just for web applications,   it's just a general programming language.   We're gonna cover all the Ruby basics you need   to get started.   However, it will be a great benefit   if at some point you learn Ruby in depth.   Everything in Ruby on Rails   is built in the Ruby programming language.   So it's common sense that you'll be a better Rails developer   if you know Ruby well.   Ruby's the foundation on which Ruby on Rails is built.   In fact, personally Ruby is the thing   that I like most about Ruby o...