A language and a framework are different tools
Ruby is a programming language. Its syntax and standard features let you write scripts, command-line tools, tests, backend services and other programs. A short file containing puts "Hello" is a Ruby program; it needs a Ruby runtime, but it does not need a web framework.
Ruby on Rails, usually called Rails, is a web application framework written in Ruby. A framework supplies an organised starting structure and reusable tools for a particular kind of application. Rails helps a team handle web requests, generate responses, work with databases and organise application code. You write Ruby when building a Rails app, but learning Ruby does not require installing Rails.
| Question | Ruby | Ruby on Rails |
|---|---|---|
| What is it? | A general-purpose programming language. | A web application framework written in Ruby. |
| What can I build? | Scripts, tools, services, tests and more. | Web applications and APIs using Rails conventions and components. |
| Do I need the other? | No—Ruby runs independently of Rails. | Yes—Rails applications run Ruby code with a compatible Ruby setup. |
What Ruby can do without Rails
The example below defines a method that builds a greeting, then prints it. Save it as greeting.rb and run ruby greeting.rb after installing Ruby locally. Expected output: Hello, Sam! There is no Rails application, server, route or database involved.
A real Ruby-only project might rename downloaded files, summarise a CSV export or provide a command-line tool for a team. Ruby libraries can add capabilities when a project needs them, but the language remains usable on its own. Beginners should first be comfortable with values, methods, collections and errors.
How Rails organises a web request
A browser or another client sends a request to a web application. Rails routing matches the request’s URL and HTTP method to a controller action. A controller coordinates the work; a model can represent domain data and, when appropriate, store and retrieve database records; a view can turn data into HTML. This broad separation is called MVC: Model–View–Controller.
For example, a request to view a book might reach a books route, then a controller action that loads the book, and finally a view that shows its title. An API action may return JSON instead of an HTML view. Rails contains more components than this simple flow, and a model does not have to be a database table in every design. The point for a beginner is that Rails gives web-specific structure around ordinary Ruby code.
- A client requests a URL.
- A route selects a controller action.
- The controller performs the request’s work, possibly using a model.
- A view or response formatter returns HTML or JSON.
Why Rails attracted developers
Rails became popular because it made common web-application work faster to start and more consistent across projects. Its “convention over configuration” approach provides defaults for names and project structure, while its reusable components handle many tasks a team would otherwise build repeatedly. The rise of Rails also introduced many developers to Ruby.
Conventions are helpful when they fit a project, but they do not remove the need to understand HTTP, data modelling, security, testing and deployment. Rails is not “Ruby with extra syntax”; it is a substantial set of libraries and conventions that runs on Ruby. You can choose it later if your goal is a web app.
Rails is one choice in the Ruby ecosystem
Sinatra is another Ruby web framework with a smaller starting structure; it can help explain the idea of a route without the whole Rails application layout. RSpec is a testing library, not a web framework. Neither is part of Ruby’s core language. Gems are packages that provide these kinds of extra tools.
Start with Ruby fundamentals even if Rails is your eventual goal. Once you can read a method, a class and a collection, Rails guides will be easier to follow because the Ruby code inside them will be familiar.
Syntax
puts "Hello from Ruby"Examples
A Ruby program without Rails
Save as greeting.rb and run locally. Expected output: Hello, Sam!
def greeting(name)
"Hello, #{name}!"
end
puts greeting("Sam")- def defines a Ruby method named greeting that accepts one argument called name.
- The final expression builds and returns a String using interpolation.
- The last line calls the method with Sam and prints the returned greeting.
- This works with Ruby alone; no Rails application or web server is involved.
Best practices
- Learn the language before adding a web framework; Rails is optional for Ruby programs.
- Describe Rails features as framework capabilities, not built-in Ruby syntax.
- Choose a library or framework for a concrete project need rather than installing everything at the start.
Runtime & versions
Ruby interpreter. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Ruby documentation