Ruby On Rails-Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

ABSTRACT

This report is regarding the project on Ruby on Rails. It was used to create the back end of
the blogging web app .

Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under
the MIT License. Rails is a model–view–controller (MVC) framework, providing default
structures for a database, a web service, and web pages. It encourages and facilitates the use
of web standards such as JSON or XML for data transfer, and HTML, CSS and JavaScript for
display and user interfacing. In addition to MVC, Rails emphasizes the use of other well-
known software engineeringpatterns and paradigms, including convention over configuration
(CoC), don't repeat yourself (DRY), and the active record pattern.

1
TABLE OF CONTENTS

Topic Page Number

Company’s Profile 6
Chapter 1: Introduction 7
Chapter 2: Technical Overview 8-10
2.1 Framework 8-9
2.2 Framework Structure 10
2.3 Deployment 10

Chapter 3: Environment Setup and Deployment 11


Chapter 4 : Project 12-16
4.1 Introduction 12
4.2 Structure 13
4.3 Use of Ruby on Rails 14
4.4 Commands 15
4.5 Features 16

Chapter 5: Live Project Details 17


Conclusion 18
References 19

2
COMPANY’S PROFILE

Company Name: Ducat Pvt. Ltd.

Address: A-52 & A-43, Sector-16, Noida, Uttar Pradesh 201301

Website : www.ducatindia.com

About the Company: Like other educational and training industry at Ducat you will
beoffered varieties programs but the instructors makes the difference and make Ducat stand
out from others. We have a variety of skilled and trained trainers whose approach is different
which you can see anywhere. Ducat contributes a lot to the knowledge of its trainees and we
try our level hard to contribute the best to increase our trainee’s ability so that they stand out
from others and whatever they contribute to the corporate world automatically becomes
productive.
Not only the fresher but also the corporates who arenot able to deal with the rising technology
and software are also helped here. We try our level best to deliver our services to every corner
of the world by the help of customized education. Our motto is to deliver the best services to
you and that is why we have taken the customized approach because we do not want you to
compromise with your education.

3
CHAPTER 1

INTRODUCTION

Rails is a web application development framework written in the Ruby programming


language. It is designed to make programming web applications easier by making
assumptions about what every developer needs to get started. It allows you to write less code
while accomplishing more than many other languages and frameworks. Experienced Rails
developers also report that it makes web application development more fun.

Rails is opinionated software. It makes the assumption that there is a "best" way to do things,
and it's designed to encourage that way - and in some cases to discourage alternatives. If you
learn "The Rails Way" you'll probably discover a tremendous increase in productivity. If you
persist in bringing old habits from other languages to your Rails development, and trying to
use patterns you learned elsewhere, you may have a less happy experience.

The Rails philosophy includes two major guiding principles:

 Don't Repeat Yourself: DRY is a principle of software development which states


that "Every piece of knowledge must have a single, unambiguous, authoritative
representation within a system." By not writing the same information over and over
again, our code is more maintainable, more extensible, and less buggy.
 Convention Over Configuration: Rails has opinions about the best way to do many
things in a web application, and defaults to this set of conventions, rather than require
that you specify minutiae through endless configuration files.

4
CHAPTER 2

Technical Overview

2.1 Framework

Like other web frameworks, Ruby on Rails uses the model–view–controller (MVC) pattern
to organize application programming.

Model

In a default configuration, a model in the Ruby on Rails framework maps to a table in a


database and to a Ruby file. For example, a model class User will usually be defined in the
file 'user.rb' in the app/models directory, and linked to the table 'users' in the database. While
developers are free to ignore this convention and choose differing names for their models,
files, and database table, this is not common practice and is usually discouraged in
accordance with the "convention-over-configuration" philosophy.

Controller

A controller is a server-side component of Rails that responds to external requests from the
web server to the application, by determining which view file to render. The controller may
also have to query one or more models for information and pass these on to the view. A
controller may provide one or more actions. In Ruby on Rails, an action is typically a basic
unit that describes how to respond to a specific external web-browser request. Also, note that
the controller/action will be accessible for external web requests only if a corresponding route
is mapped to it. Rails encourages developers to use RESTful routes, which include actions
such as create, new, edit, update, destroy, show, and index. These mappings of incoming
requests/routes to controller actions can be easily set up in the routes.rb configuration file.

5
View
A view in the default configuration of Rails is an erb file, which is evaluated and converted to
HTML at run-time. Alternatively, many other templating systems can be used for views.

Tools

Ruby on Rails includes tools that make common development tasks easier "out-of-the-box",
such as scaffolding that can automatically construct some of the models and views needed for
a basic website. Ruby on Rails is most commonly not connected to the Internet directly, but
through some front-end web server. Passenger replaced Mongrel as the most-used web server
for Ruby on Rails. Ruby is also supported natively on the IBM i.

Ruby on Rails is also noteworthy for its extensive use of the JavaScript libraries, Prototype
and Script.aculo.us, for scripting Ajax actions.Ruby on Rails initially utilized lightweight
SOAP for web services; this was later replaced by RESTfulweb services.

Fig 1

6
2.2 Framework structure

Ruby on Rails is separated into various packages, namely ActiveRecord (an object-relational
mapping system for database access), Active Resource (provides web services), Action Pack,
Active Support and Action Mailer. Prior to version 2.0, Ruby on Rails also included the
Action Web Service package that is now replaced by Active Resource. Apart from standard
packages, developers can make plugins to extend existing packages. Earlier Rails supported
plugins within their own custom framework; version 3.2 deprecates these in favor of standard
Ruby "gems".

2.3 Deployment

Ruby on Rails is often installed using RubyGems, a package manager which is included with
current versions of Ruby. Many free Unix-like systems also support installation of Ruby on
Rails and its dependencies through their native package management system.

Ruby on Rails is typically deployed with a database server such as MySQL or PostgreSQL,
and a web server such as Apache running the Phusion Passenger module.

7
CHAPTER 3

Environment Set Up and Deployment

Installation on Windows

Installation in windows is very easy, actually it’s a one click installation.Follow following
steps to install ruby on rails with everything.

– Navigate to: http://www.railsinstaller.org/en/


– Scroll down to "Ruby on Windows"
– Download the "One-click Installer"
– Follow the install instructions
• Include RubyGems if possible (this will be necessary for Rails
installation later)

Git

Git is a version control system for tracking changes in computer files and coordinating work
on those files among multiple people.
It is installed with the one click installer.

Heroku

Heroku is a cloud platform as a service (PaaS) that support several programing languages.
Perform following steps -
1. Create an account onheroku.
2. Create new app
3. Add files to heroku app
4. Open app using app link

8
CHAPTER 4

Project

4.1 Introduction

The project made using ruby on rails is a web app, which is a blog website named
KeshavRBlog. It is a website in which we can see various posts as shown in figure.
It includes blogs for the public which everyone can see the posts and a authorized area for the
admin by which the admin can add , update , delete posts.

Fig 2

9
4.2 Structure

When you use the Rails helper script to create your application, it creates the entire directory
structure for the application. Rails knows where to find things it needs within this structure,
so you don't have to provide any input.

Here is a top-level view of a directory tree created by the helper script at the time of
application creation. Except for minor changes between releases, every Rails project will
have the same structure, with the same naming conventions. This consistency gives you a
tremendous advantage; you can quickly move between Rails projects without relearning the
project's organization.

Fig 3

10
4.3 Use of Ruby on Rails

A recommended work flow for creating Rails Application is as follows −

 Use the rails command to create the basic skeleton of the application.

 Create a database on the PostgreSQL server to hold your data.

 Configure the application to know where your database is located and the login
credentials for it.

 Create Rails Active Records (Models), because they are the business objects you'll be
working with in your controllers.

 Generate Migrations that simplify the creating and maintaining of database tables and
columns.

 Write Controller Code to put a life in your application.

 Create Views to present your data through User Interface.

Fig 4

11
4.4 Commands

$rails new rblog

This command is used to create the basic structure of the app.It creates the entire structure
which include model,view, comtroller , databases, css.

$rails server

The rails server command launches a web server named Puma which comes bundled with
Rails. You'll use this any time you want to access your application through a web browser.

$rails generate controller posts index

This is used to create a controller named posts. Which will create a view index.

$rails console

The console command lets you interact with your Rails application from the command line.
On the underside, rails console uses IRB, so if you've ever used it, you'll be right at home.
This is useful for testing out quick ideas with code and changing data server-side without
touching the website.

$rails destroy model Oops

Think of destroy as the opposite of generate. It'll figure out what generate did, and undo it

12
4.5 Features

Admin Interface

In the project there is a admin interface that allows to login to the site . The admin get greater
control and he can edit the posts and the categories.

Fig 5
Adding Posts and Categories

The admin get greater control and he can edit the posts and the categories.You can edit posts
directly by gui on the website only.
Sort the posts acording to parameters.

Fig 6

13
CONCLUSION

Ruby on Rails is a great framework for creating advanced web applications writing very little
code in comparison to what you get. I recommend it for almost any kind of application, and
especially for prototyping. To inspire you, I created a video where I create a blog in 10
minutes using Ruby on Rails. Check it out and be sold. I also recommend the documentation
section of the official Ruby on Rails site. For those of you used to Ruby on Rails, I
recommend this blog post about the changes from version 3.0 to version 3.1.

It encourages and facilitates the use of web standards such as JSON or XML for data
transfer, and HTML, CSS and JavaScript for display and user interfacing. In addition to
MVC, Rails emphasizes the use of other well-known software engineering patterns and
paradigms, including convention over configuration (CoC), don't repeat yourself (DRY), and
the active record pattern.

14
15

You might also like