Creating your First Ruby on Rails (RoR) application using scaffolding on Windows with Rails in 7 Steps
We will use Bitnami
Ruby stack on Windows Environment through out this article
If you are absolute beginner and need to start from knowing what is Ruby and
Rails try below links
Once you get acquaint with basic syntax of Ruby try out basic ruby code snippets
in an interactive shell like web environment here at http://tryruby.org
Prerequisites
for this article:
Bitnami Ruby
Stack: (You can download the Bitnami installer at URL).
Once installed it starts appearing in your start menu as
Start > All Programs > Bitnami Ruby
Stack
Bitnami Ruby
Stack is an Ruby environment with Rails and other software stacks like Apache
, MySQL , PostgreSQL. It is good starting point when you start learning RoR
development since here you need not struggle with RoR installation and other
configurations, Remember that Bitnami Ruby Stack is for development purpose
only. And I further feel that Production RoR environment should be using Linux
and nginx as Web Container.
So lets
start developing our first application in RoR by using scaffolding.
But what is Scaffolding in RoR ??
Rails scaffolding is a quick way to generate models, views, and controllers for
a new resource in a single operation, scaffolding is the tool for the job to be
get it done quickly. Scaffolding should be used as a starting point but for
creating production scale application many developers prefer writing their own
code. Let’s use scaffolding here to generate a simple application in which we
will model an application which stores names and their emails.
Let’s begin
Step 1: Open your Ruby console
Go to Start > All Programs > Bitnami Ruby Stack > Use Bitnami Ruby Stack.
Go to Start > All Programs > Bitnami Ruby Stack > Use Bitnami Ruby Stack.
Step 2: You will find a console into the
directory where you have installed Bitnami Ruby Stack.
In my case
its “C:\Bitnami\rubystack-1.9.3-22”
type “ruby –v“ to get verison of Ruby and “rails –v ” to get version of Rails
Step 3: Type following command to create a
new Rails project. Ensure that at this point of time you have active internet
connection.
rails new projects/emailcontactsapp
this command
creates entire project structure specific to RoR in directory C:\Bitnami\rubystack-1.9.3-22\projects\emailcontactsapp
and installs ruby gems required for the application . It stops for a moment ,
typically 5-10 minutes depending upon your internet bandwidth , till all required
gem files are installed.
The output
window after successful execution of command will be as
Step 4:
The command executed in Step 3 creates blank project structure with essential
files for an RoR application. Once the project has been created its time to
create a model and scaffold for the model created. We need to take note that
RoR apps are MVC apps so creating model implies that you need to create View
and Controller entities. Here since we are using scaffolding approach we only
specify the model name and Controllers, Views are generated as to allow basic
CRUD style operations.
Lets generate the model with name contacts which would store name and email, hence we will choose our database to contain two fields namely “Name as string” and “Email as string”
Lets generate the model with name contacts which would store name and email, hence we will choose our database to contain two fields namely “Name as string” and “Email as string”
cd into the
application directory with command
cd projects\emailcontactsapp
cd projects\emailcontactsapp
And the command
to generate scaffold will be
rails generate scaffold contacts Name:string Email:string
rails generate scaffold contacts Name:string Email:string
Your command
prompt screen should look somewhat like screenshot below after the command successfully
executes.
You can
observe that we have specified that we are using scaffold and contacts as model name and “Name” of type
string and “Email” of type string as two fields of database.
Here it’s
important to know that we are not creating database, it will be created in
further steps by issuing command “rake db:migrate” . Also we are using default
sqlite3 as database backend for our model. In case you wish to use Database
servers like MySQL , Oracle , and others you need to install required gems and
specify database connection and access credentials in file
<project-path>/config/database.yml. Let’s stick to sqlite3 as of now. Following are further types of fields supported in scaffolding
<project-path>/config/database.yml. Let’s stick to sqlite3 as of now. Following are further types of fields supported in scaffolding
:binary
:boolean
:date
:datetime
:decimal
:float
:integer
:primary_key
:string
:text
:time
:timestamp
:boolean
:date
:datetime
:decimal
:float
:integer
:primary_key
:string
:text
:time
:timestamp
Step 5: Now that we have generated Model, Views
and Controllers , the only thing remaining is to create database and appropriate fields in the database which
were specified as a part of scaffold command. Inour case those fields were Name
and Email.
Its quite easy just execute command
Its quite easy just execute command
rake db:migrate
Output
should be stating that “created migrating …..” look at the screenshot below
Step 6: Now its all done , just we need to
start the development server and your contacts RoR app is ready and functioning
To start the
development server type the command
rails server
Note down
the port number at which development started , in most cases the port number
would be 3000. In case if ports are already in use try killing the process
which is using the concerned port and retry the command to start development
server.
Alternatively you can also specify the port number at which you intend to start the development server
by command rails server -p <port number>
by command rails server -p <port number>
You can see
that in my case development server started at port number 3000
Let’s browse
the URL http://localhost:3000/
you will find the default webpage which we are not interested rather we are interested in the Views created by scaffolding.
you will find the default webpage which we are not interested rather we are interested in the Views created by scaffolding.
To view
those Views
Go the URL http://localhost:3000/contacts
you will see that I appended the model name which I have created during Step 4.
Below are the screenshots when you visit various links on the application. You can see that you are able to add new contact , delete, modify, and show the contacts.
you will see that I appended the model name which I have created during Step 4.
Below are the screenshots when you visit various links on the application. You can see that you are able to add new contact , delete, modify, and show the contacts.
Step 7: To shutdown the development server
hit Cntrl+C
Hope you got your first RoR app running !!! Happy coding !!
Screenshots of output of application running on development server.
Your post has many detail information. I read all of your article and I genuinely like it. Thank you for discussing this great post.
ReplyDelete- hide online
Convex Optimization Based State Estimation against Sparse Integrity Attacks Project For CSE
DeleteDeQoS Attack Degrading Quality of Service in VANETs and its Mitigation Project For CSE
HEDGE Efficient Traffic Classification of Encrypted and Compressed Packets. Project For CSE
Large Scale Analysis of Regularized Block Diagonalization Precoding for Physical Layer Security of Multi User MIMO Wireless Networks Project For CSE
Novel Properties of Successive Minima and Their Applications to 5G Tactile Internet Project For CSE
Very informative blog! I am glad that I came across your article. I'm learning a lot from here. Keep us updated by sharing more such blogs.
ReplyDeleteWordPress Training in Chennai
WordPress Training Chennai
Unix Training in Chennai
Unix Shell Scripting Training in Chennai
LINUX Training in Chennai
LINUX Course in Chennai
WordPress Training in Anna Nagar
WordPress Training in Velachery
Awesome blog with lots of information. It is really helpful for all.
ReplyDeleteDevOps course in Chennai
Best DevOps Training in Chennai
Amazon web services Training in Chennai
AWS Certification in Chennai
Data Analytics Courses in Chennai
Big Data Analytics Courses in Chennai
DevOps Training in Anna Nagar
DevOps Training in T Nagar
thanks for sharing this informations
ReplyDeleteaws training center in chennai
aws training in chennai
aws training institute in chennai
best angularjs training in chennai
angularjs training in chennai
azure training in chennai
best devops training in chennai
Thanks for sharing
ReplyDeleteAWS Training in Chennai
Blueprism Training in Chennai
Uipath Training in Chennai
Basically, the worth and importance of data can be understood by the mere fact that a proper store/warehouse of data is a million times more valuable than a mine of pure gold in the modern world. data science course syllabus
ReplyDeleteI’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one
ReplyDeletedata science course in India
instagram takipçi satın al - instagram takipçi satın al - tiktok takipçi satın al - instagram takipçi satın al - instagram beğeni satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - instagram beğeni satın al - instagram beğeni satın al - polen filtresi - google haritalara yer ekleme - btcturk güvenilir mi - binance hesap açma - kuşadası kiralık villa - tiktok izlenme satın al - instagram takipçi satın al - sms onay - paribu sahibi - binance sahibi - btcturk sahibi - paribu ne zaman kuruldu - binance ne zaman kuruldu - btcturk ne zaman kuruldu - youtube izlenme satın al - torrent oyun - google haritalara yer ekleme - altyapısız internet - bedava internet - no deposit bonus forex - erkek spor ayakkabı - webturkey.net - minecraft premium hesap - karfiltre.com - tiktok jeton hilesi - tiktok beğeni satın al - microsoft word indir - misli indir
ReplyDeletetakipçi satın al
ReplyDeletetakipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
instagram takipçi satın al
marsbahis
ReplyDeletebetboo
sultanbet
marsbahis
betboo
sultanbet
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeleteOracle Fusion HCM Training
Workday Training
Okta Training
Palo Alto Training
Adobe Analytics Training
instagram beğeni satın al
ReplyDeleteyurtdışı kargo
seo fiyatları
saç ekimi
dedektör
fantazi iç giyim
sosyal medya yönetimi
farmasi üyelik
mobil ödeme bozdurma
bitcoin nasıl alınır
ReplyDeletetiktok jeton hilesi
youtube abone satın al
gate io güvenilir mi
referans kimliği nedir
tiktok takipçi satın al
bitcoin nasıl alınır
mobil ödeme bozdurma
mobil ödeme bozdurma