Ruby is
A
High Level Programming Language
Object-Oriented Like Smalltalk, Eiffel, Ada, Java.
Interpreted like Perl, Python, Tcl/TK.
Object-Oriented Like Smalltalk, Eiffel, Ada, Java.
Interpreted like Perl, Python, Tcl/TK.
Ruby
is becoming popular because
- Easy to learn
- Open source (very
liberal license)
- Rich libraries
- Very easy to extend
- Truly Object-Oriented
- Less Coding with fewer
bugs
- Helpful community
Sample Ruby Code
# The Hello Class
class Hello
def initialize( name )
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
# Create a new object
h = Hello.new("Ruby")
# Output "Hello Ruby!"
h.salute
Embedded Ruby
Ruby
provides you with a program called ERb (Embedded Ruby). ERb allows you to put
Ruby code inside an HTML file. ERb reads along, word for word, and then at a
certain point when it sees the Ruby code embedded in the document it sees that
it has to fill in a blank, which it does by executing the Ruby code.
Sample
embedded ruby code
<% page_title = "Demonstration of ERb" %>
<% salutation = "Dear programmer," %>
<html>
<head>
<title><%= page_title %></title>
</head>
<body>
<p><%= salutation %></p>
<p>This is an example of how ERb fills out a template.</p>
</body>
</html>
Rails
Rails is a web application development
framework written in the Ruby 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.
The Rails philosophy includes
several guiding principles:
·
DRY –
“Don’t Repeat Yourself” – suggests that writing the same code over and over
again is a bad thing.
·
Convention
Over Configuration – means that Rails makes assumptions about what you want to
do and how you’re going to do it, rather than requiring you to specify every
little thing through endless configuration files.
·
REST is
the best pattern for web applications – organizing your application around
resources and standard HTTP verbs is the fastest way to go.
Setup
1.
Install Ruby
193 (installed) and set path
2.
Install
rails
a.
Gem install
rails –p http://proxy.talx.com:18717
(this will install the latest version of rails)
3.
Create a
folder for website using
a.
Rails new
appname
4.
Also install
these
a.
Jquery-rails
b.
Coffee-rails
c.
Sqlite3
d.
Sass-rails
e.
Uglifier
5.
Go to the
appname folder
a.
Rails server
b.
Access
localhost:3000