<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/blog/padrino-framework-basics" -->

---
title: Padrino Framework Basics | daily.dev
description: Practical overview of Padrino, a Sinatra-based Ruby web framework: install, project scaffolding, mountable apps, routing, views, forms, and admin tools.
canonical: https://daily.dev/blog/padrino-framework-basics/
og:type: article
og:url: https://daily.dev/blog/padrino-framework-basics/
og:title: Padrino Framework Basics | daily.dev
og:description: Practical overview of Padrino, a Sinatra-based Ruby web framework: install, project scaffolding, mountable apps, routing, views, forms, and admin tools.
og:image: https://media.daily.dev/image/upload/s--Al0JFSUK--/f_auto,q_auto/v1/recruiter-landing/69bde5d51b352ff267cb3554_1774065123008_23fd44d75b?_a=BAMAMiB80
og:site_name: daily.dev
og:locale: en_US
article:published_time: 2026-03-21
article:modified_time: 2026-06-10T06:16:13.224Z
article:author: Alex Carter
twitter:card: summary_large_image
twitter:site: @dailydotdev
twitter:creator: @dailydotdev
twitter:title: Padrino Framework Basics | daily.dev
twitter:description: Practical overview of Padrino, a Sinatra-based Ruby web framework: install, project scaffolding, mountable apps, routing, views, forms, and admin tools.
twitter:image: https://media.daily.dev/image/upload/s--Al0JFSUK--/f_auto,q_auto/v1/recruiter-landing/69bde5d51b352ff267cb3554_1774065123008_23fd44d75b?_a=BAMAMiB80
---

[Padrino](http://padrinorb.com/) is a **[Ruby](https://www.ruby-lang.org/en/) web framework** built on [Sinatra](https://sinatrarb.com/), offering added features like mailers, caching, admin interfaces, and view helpers. It balances [Sinatra](https://sinatrarb.com/)'s simplicity with the ability to handle more complex applications. Released in 2010, its latest version (0.16.0) supports Ruby 3.4 and [Rack](https://rack.github.io/) 3.0. Here’s a quick breakdown of what makes Padrino a go-to choice for developers:

-   **Flexibility**: Choose your preferred ORM, testing framework, and renderer.
-   **Admin Interface**: Includes authentication, permissions, scaffolding, and localization in 10 languages.
-   **Modular Design**: Supports multiple sub-applications in a single project.
-   **Compatibility**: Works well for those transitioning from Sinatra but not ready for Rails.

#Padrino is built around the idea of "graduated complexity": start as small as a single Sinatra-style file and grow into routing, middleware, and a modular multi-app structure as the project demands. It runs on any Rack-compatible server such as [Puma](https://puma.io/) or Thin. To get started, install it with `gem install padrino` and scaffold a project.

## Getting Started with [Padrino](http://padrinorb.com/)

![Padrino](https://assets.seobotai.com/daily.dev/69bde5d51b352ff267cb3554/3011c842787eb259471ea2682a89bef5.jpg)

### Prerequisites

Before diving in, make sure you have **Ruby 2.7.8** or a newer version installed. You can confirm your Ruby and gem versions by running:

```bash
ruby -v
gem -v
```

You'll also need **[RubyGems](https://rubygems.org/)** for managing packages and **[Bundler](https://bundler.io/)** to handle project dependencies. If you're on Windows, the **[RubyInstaller](https://rubyinstaller.org/)** is a great tool to set up your environment. To manage Ruby versions effectively, consider using tools like **[RVM](https://rvm.io/)** or **asdf**.

Since Padrino builds on Sinatra, having a basic grasp of [Sinatra's routing and its request/response cycle](https://daily.dev/blog/sinatra-for-ruby-setup-routing-sessions-deployment) will be helpful. All Sinatra extensions integrate seamlessly with Padrino, so any existing knowledge will come in handy.

Once your environment is ready, you're all set to install Padrino.

### Installing Padrino

To install Padrino, simply run:

```bash
gem install padrino
```

This will also install **Sinatra ~> 4.0** and **Rack >= 3.0** automatically [\[2\]](https://www.padrinorb.com/blog). Keep in mind that Ruby 3.0 no longer includes WEBrick in its standard library. Because of this, you’ll need to add an HTTP server like `puma`, `thin`, or `webrick` to your Gemfile explicitly.

### Creating Your First Project

After installing Padrino, you can scaffold a new project quickly. Use the following command to generate your project:

```bash
padrino g project your_project_name
```

During the setup, you'll be prompted to select options like your preferred ORM, testing framework, template engine, and HTTP server. For instance, if you want to use **[ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html)**, **[RSpec](https://rspec.info/)**, **[Haml](https://haml.info/)**, and **Puma**, while also running `bundle install` automatically, you can use:

```bash
padrino g project my_app -d activerecord -t rspec -e haml --server puma -b
```

Once the project is created, navigate into the project directory:

```bash
cd my_app
```

To set up your database, run:

```bash
bundle exec rake db:create
bundle exec rake db:migrate
```

Then, start your application with:

```bash
padrino start
```

Alternatively, you can use the shorthand:

```bash
padrino s
```

By default, your app will run at http://localhost:3000. To see all your application's routes and controller mappings, execute:

```bash
padrino rake routes
```

One of Padrino's standout features is its auto-reloader, which detects file changes and refreshes the server automatically, making development faster and smoother.

###### sbb-itb-bfaad5b

## Padrino's Architecture

Padrino uses a **mountable architecture** that allows you to integrate multiple sub-applications within one project directory [\[3\]](https://www.padrinorb.com/guides/getting-started/basic-projects)[\[6\]](https://padrinorb.com/guides/03_features/05_mounting-applications). Essentially, your project serves as a container, while each sub-application - whether it's a web front-end, an admin panel, or an API - functions as a modular unit mounted within the project. This modularity is similar to how developers use [specialized developer apps](https://daily.dev/apps) to manage different parts of their workflow. This setup makes it easier to manage and scale complex systems within a single codebase.

> "Padrino has been principally structured and designed for mounting multiple applications at the same time." - Padrino Documentation [\[3\]](https://www.padrinorb.com/guides/getting-started/basic-projects)

The framework initializes through `config/boot.rb`, which handles dependency loading, setup, and the all-important `Padrino.load!` command that boots the framework and activates all mounted applications [\[4\]](https://padrinorb.com/guides/03_features/06_development-commands). The `config/apps.rb` file is where you define how these applications are mounted using commands like `Padrino.mount('app_name').to('/path')` [\[6\]](https://padrinorb.com/guides/03_features/05_mounting-applications). You can map each application to specific URI namespaces or even different hosts [\[6\]](https://padrinorb.com/guides/03_features/05_mounting-applications).

### Application Structure

Once your project is up and running, you'll see a well-organized directory structure. Key directories include:

-   **`app/`**: Houses controllers, views, and helpers for your application.
-   **`models/`**: Contains shared data models.
-   **`lib/`**: Used for custom modules and libraries.
-   **`public/`**: Stores static assets like images, CSS, and JavaScript.

For projects with multiple applications, shared models can be stored in `project/shared/models` or the root `models/` directory to ensure accessibility across all sub-applications [\[4\]](https://padrinorb.com/guides/03_features/06_development-commands). If you need to add a new module, you can use the command `padrino g app <name>`, which automatically updates the `config/apps.rb` file for you [\[3\]](https://www.padrinorb.com/guides/getting-started/basic-projects).

### Routing Basics

Padrino's modular design extends to its routing system, which helps keep your application's logic clean and organized. Routes are grouped within `controller` blocks, making it easier to manage related functionality and create URLs [\[5\]](https://padrinorb.com/guides/controllers/overview). Named aliases (e.g., `get :index`) and namespacing (e.g., `controllers :admin`) allow you to automatically prefix URLs, while the `url_for` helper simplifies referencing routes throughout the app.

For more advanced routing, you can use the `:with` option to define named parameters, like `get :show, with: :id`, which makes parameters accessible via `params[:id]`.

Padrino also supports route prioritization. High-priority routes are checked first, making them ideal for overrides, while low-priority routes are better for catch-all patterns. If you need custom URL structures, the `map` option lets you define them explicitly (e.g., `get :index, map: '/custom/path'`).

### Middleware and Configuration

Built on the **Rack interface**, Padrino connects Ruby web servers like Puma or Thin to your application. Middleware plays a vital role in handling system-level tasks. For example, `Padrino::Reloader` monitors application files and reloads them in development mode without requiring a server restart [\[4\]](https://padrinorb.com/guides/03_features/06_development-commands).

Configuration is managed through two main files:

-   **`app/app.rb`**: For application-specific settings.
-   **`config/apps.rb`**: For project-wide mounting and configuration.

Since Padrino applications inherit from `Padrino::Application` (which itself extends `Sinatra::Base`), you can use Sinatra's configuration DSL with commands like `set`, `enable`, and `disable`. Environment-specific blocks in `app.rb` allow you to toggle features based on the environment. For example, you might enable template reloading or adjust logging levels with conditions like `if Padrino.env == :production`.

If you’re using non-standard directories, you can include them in the `prerequisites` list within `Padrino.after_load` in `config/boot.rb`. This ensures they are autoloaded and reloaded as needed [\[4\]](https://padrinorb.com/guides/03_features/06_development-commands).

## Working with Views and Forms

After setting up your application's architecture and routing, Padrino equips you with helpful tools to simplify UI development. These include view helpers and form-handling features that reduce repetitive code and keep things organized.

### View Helpers

Padrino's view helpers make it easy to create and manage HTML elements. For instance, the `tag` method generates self-closing tags, while `content_tag` wraps content in a specified HTML tag with attributes. For example:

```ruby
content_tag(:div, 'Hello', class: 'greeting')
```

This produces a `<div>` element with the class "greeting" and the text "Hello."

Other helpers, like `content_for` and `yield_content`, are great for managing layout-specific content. You can use `content_for :assets` in a view to define unique styles or scripts, and then render them in the layout's `<head>` using `yield_content :assets`.

Need reusable templates? The `partial` helper has you covered. Instead of manually iterating through collections, you can use:

```ruby
partial 'path/to/item', collection: @items
```

This keeps your code modular and easier to maintain.

### Form Handling

Forms can be a hassle, but Padrino simplifies the process with tools like `form_tag` for basic forms and `form_for` for forms tied to specific models. The `form_for` helper uses the `StandardFormBuilder` to map model attributes to input fields and even display validation errors with `error_messages_for`.

If you're working with nested objects, `fields_for` allows you to manage related data in a single form. For example, when using `form_for :user`, submitted data is automatically mapped to `params[:user]`. Padrino also supports non-standard HTTP methods like PUT and DELETE by generating a hidden `_method` field to bypass browser limitations.

Want to customize your forms? You can create a custom form builder by inheriting from `AbstractFormBuilder` and configuring it as your application's `default_builder`. This ensures consistent styling and behavior across all forms.

### Unobtrusive JavaScript

Padrino integrates unobtrusive JavaScript (UJS) to enable dynamic interactions without cluttering your HTML. Adding `remote: true` to `form_for` or `link_to` automatically includes a `data-remote="true"` attribute, triggering an XHR request instead of a full page reload. You can also use options like `confirm: 'Message'` to add confirmation dialogs or `method: :delete` to simulate HTTP verbs beyond GET and POST.

To use these features, include the necessary JavaScript libraries and UJS adapters in your layout:

```ruby
= javascript_include_tag 'jquery', 'jquery-ujs'
```

For remote forms or links, ensure your URL helpers specify the JavaScript format, like `url(:items, :create, format: :js)`. This makes sure your controller responds appropriately with JavaScript. And for actions that modify or delete data, always pair `method: :delete` with `confirm: 'Are you sure?'` to maintain [RESTful API design best practices](https://daily.dev/blog/restful-api-design-best-practices-guide-2024) and prevent accidental changes.

## Building Your First Padrino Application

Now that we've covered the basics of views and forms, let's dive into creating a practical blog application. This example will walk you through how Padrino's tools and conventions can simplify and speed up development, much like the [Ruby on Rails](https://daily.dev/blog/ruby-on-rails-beginners-guide-2024) framework.

### Generating the Project

To get started, generate your blog project using this command:

```bash
padrino g project blog -d activerecord -t rspec -e haml -c scss -s jquery -b
```

Here’s what each option specifies:

-   **\-d activerecord**: Sets ActiveRecord as the ORM.
-   **\-t rspec**: Chooses RSpec for testing.
-   **\-e haml**: Uses Haml for templating.
-   **\-c scss**: Selects SCSS for stylesheets.
-   **\-s jquery**: Includes jQuery for JavaScript.
-   **\-b**: Automatically runs `bundle install` after generating the project.

After running the command, move into your project directory:

```bash
cd blog
```

If your app needs a database, configure the connection details in `config/database.rb`. For SQLite, you can include the **\-a sqlite** flag during project generation. Then, set up the database schema by running:

```bash
padrino rake sq:migrate
```

Next, create a `Post` model with fields using this command:

```bash
padrino g model Post title:string body:text published_at:datetime
```

This will generate the model and its corresponding migration. Run the migration immediately to keep the database schema updated. Afterward, set up an admin interface by running:

```bash
padrino g admin
```

Initialize the admin account with these commands:

```bash
rake db:create
rake db:migrate
rake db:seed
```

With the basic setup complete, it's time to build the application's views.

### Adding Views and Templates

In Padrino, views are stored in the `app/views` directory and are grouped by controller name. Since we specified Haml (`-e haml`), template files will use the `.haml` extension. Start by creating a layout file at `app/views/layouts/application.haml`. Use a `yield` statement in this file to mark where the view content should be inserted.

For the blog's index page, create a template at `app/views/posts/index.haml`. To keep your code modular and clean, use the `partial` helper. For instance:

```ruby
= partial 'posts/post', collection: @posts
```

This will render the `_post.haml` partial for each post in the `@posts` collection. You can also include navigation links with the `link_to` helper and manage assets using `stylesheet_link_tag` or `javascript_include_tag`.

Padrino automatically determines the correct template based on the rendering engine and locale. For example, calling `render 'posts/index'` will find the right file without needing to specify the extension. If you want to disable layouts for specific routes, add `layout: false` to your `render` call.

With your views ready, the next step is to implement CRUD functionality.

### Implementing CRUD Functionality

Padrino’s modular design makes CRUD operations straightforward. The admin generator simplifies creating, reading, updating, and deleting records. To set up CRUD for posts, run:

```bash
padrino g admin_page Post
```

This command generates controllers and views for managing posts. As the Padrino documentation explains:

> "Padrino Admin makes it easy to create, edit and delete records automatically."

For the public-facing site, generate a controller with:

```bash
padrino g controller posts index show
```

Define routes using named symbols like `get :index` or `get :show, with: :id` to handle specific actions. Instead of hardcoding paths, use helpers such as `url_for` or `url` for referencing routes.

In your controller actions, fetch data from the model and assign it to instance variables. For example:

-   In the `index` action:
    
    ```ruby
    @posts = Post.all
    ```
    
-   In the `show` action:
    
    ```ruby
    @post = Post.find(params[:id])
    ```
    

You can view your app’s routes anytime by running:

```bash
padrino rake routes
```

This will display the URL mappings to controller actions. To see your application in action, start the server with:

```bash
padrino s
```

Then, open your browser and visit **http://localhost:3000**. Padrino’s built-in reloader will apply any code changes without needing to restart the server.

## Conclusion

### Key Features Recap

Padrino blends the simplicity of Sinatra with tools designed to handle more complex applications. As the Padrino Development Team explains, "Our goal with Padrino is to stay true to the core principles of Sinatra including a focus on simplicity and modularity" [\[1\]](https://www.padrinorb.com). This framework takes an agnostic approach, giving you the freedom to select your preferred tools, whether it's an ORM (like ActiveRecord, Sequel, or Mongoid), a testing framework (such as RSpec, Minitest, or Cucumber), or a rendering engine (Haml, Slim, or Erb). You're not tied to rigid defaults.

One standout feature is its mountable architecture, which makes it easier to manage large projects. For instance, you can divide your application into smaller, focused sub-applications - like separating an admin panel, public-facing site, and API into distinct components. Additionally, the built-in admin interface simplifies tasks like authentication, permissions, and model scaffolding, all without requiring extra setup.

Padrino is also up-to-date with support for Ruby 3.4, Sinatra 4.0, and Rack 3.0, ensuring your projects run on modern, secure platforms [\[2\]](https://www.padrinorb.com/blog). Its gradual complexity model allows you to start small and scale up, adding features as your application grows - offering flexibility for any development pace.

These features provide a solid starting point for diving deeper into Padrino.

### Next Steps

To build on these foundational features, start with the official Blog Tutorial. It offers a step-by-step guide, complete with screencasts, to help you understand the full-stack workflow. Next, explore the Generators guide to learn how to automate project setup and customize components. Practice organizing modular projects by studying how to mount sub-applications, which is key for building scalable, multi-app systems.

Since Padrino is built on Sinatra, reviewing the Sinatra Book and its GitHub repository will deepen your understanding of the core DSL. For advanced learning, consider topics like asynchronous concurrency, integrating [Grape](https://www.ruby-grape.org/) for API development, or running Padrino on [JRuby](https://www.jruby.org/). Lastly, stay connected with the Padrino community through their official Twitter, Gitter chat, or the #padrino IRC channel on Freenode for live discussions and updates.

## FAQs

### When should I use Padrino instead of plain Sinatra?

If you're working on a project that demands more structure and built-in tools for handling complex web applications, **Padrino** might be the better choice. While it builds on Sinatra's simplicity, Padrino enhances it with features that make managing larger, more intricate projects much easier.

Some of the standout tools Padrino offers include:

-   **Admin interface**: Simplifies managing your application’s backend.
-   **Mailer**: Streamlines email handling within your app.
-   **Caching**: Boosts performance by efficiently storing and retrieving data.
-   **Localization**: Essential for projects that need multi-language support.
-   **Application mounting**: Allows you to organize and manage multiple apps within a single project.

Padrino is perfect for developers who love Sinatra’s lightweight nature but need more functionality and organization to tackle feature-packed applications.

### How do I mount multiple sub-apps in one Padrino project?

To include multiple sub-apps in a Padrino project, you can use the `mount` method within your main application. Here's a quick example:

```ruby
Padrino.mount('SubApp1').to('/subapp1')
Padrino.mount('SubApp2').to('/subapp2')
```

Each sub-app should be set up as an independent Padrino application. The main app will handle routing by directing requests to the appropriate sub-app based on the URL prefix defined in the `to()` method.

### Why do I need to add Puma, Thin, or WEBrick manually?

When using Padrino, you’ll need to manually add a web server like **Puma**, **Thin**, or **WEBrick** to your application. These servers aren’t bundled by default, so it’s up to you to install and configure one to ensure your app runs as expected.

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/og-image.png?v=a830cdf1","width":1200,"height":630},"sameAs":["https://twitter.com/dailydotdev","https://www.linkedin.com/company/dailydotdev","https://github.com/dailydotdev","https://www.instagram.com/dailydotdev"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","description":"Free, personalized developer news aggregator. Stay on top of software development news, AI coding tools, and web dev - curated daily from trusted sources.","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}},{"@type":"WebPage","@id":"https://daily.dev/blog/padrino-framework-basics/","url":"https://daily.dev/blog/padrino-framework-basics/","name":"Padrino Framework Basics | daily.dev","description":"Practical overview of Padrino, a Sinatra-based Ruby web framework: install, project scaffolding, mountable apps, routing, views, forms, and admin tools.","inLanguage":"en-US","isPartOf":{"@id":"https://daily.dev/#website"},"timeRequired":"PT12M"},{"@type":"Article","@id":"https://daily.dev/blog/padrino-framework-basics/#article","headline":"Padrino Framework Basics","url":"https://daily.dev/blog/padrino-framework-basics/","datePublished":"2026-03-21","dateModified":"2026-06-10T06:16:13.224Z","isPartOf":{"@id":"https://daily.dev/#website"},"publisher":{"@id":"https://daily.dev/#organization"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/blog/padrino-framework-basics/"},"description":"Practical overview of Padrino, a Sinatra-based Ruby web framework: install, project scaffolding, mountable apps, routing, views, forms, and admin tools.","image":{"@type":"ImageObject","url":"https://media.daily.dev/image/upload/s--Al0JFSUK--/f_auto,q_auto/v1/recruiter-landing/69bde5d51b352ff267cb3554_1774065123008_23fd44d75b?_a=BAMAMiB80"},"author":{"@type":"Person","name":"Alex Carter","url":"https://app.daily.dev/alexcarterdev"},"timeRequired":"PT12M","potentialAction":{"@type":"ReadAction","target":"https://daily.dev/blog/padrino-framework-basics/"}},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https://daily.dev/blog/"},{"@type":"ListItem","position":3,"name":"Insights","item":"https://daily.dev/categories/insights/"},{"@type":"ListItem","position":4,"name":"Padrino Framework Basics","item":"https://daily.dev/blog/padrino-framework-basics/"}]},{"@type":"FAQPage","@context":"https://schema.org","mainEntity":[{"name":"When should I use Padrino instead of plain Sinatra?","@type":"Question","acceptedAnswer":{"text":"\u003cp>If you're working on a project that demands more structure and built-in tools for handling complex web applications, \u003cstrong>Padrino\u003c/strong> might be the better choice. While it builds on Sinatra's simplicity, Padrino enhances it with features that make managing larger, more intricate projects much easier.\u003c/p> \u003cp>Some of the standout tools Padrino offers include:\u003c/p> \u003cul> \u003cli>\u003cstrong>Admin interface\u003c/strong>: Simplifies managing your application’s backend.\u003c/li> \u003cli>\u003cstrong>Mailer\u003c/strong>: Streamlines email handling within your app.\u003c/li> \u003cli>\u003cstrong>Caching\u003c/strong>: Boosts performance by efficiently storing and retrieving data.\u003c/li> \u003cli>\u003cstrong>Localization\u003c/strong>: Essential for projects that need multi-language support.\u003c/li> \u003cli>\u003cstrong>Application mounting\u003c/strong>: Allows you to organize and manage multiple apps within a single project.\u003c/li> \u003c/ul> \u003cp>Padrino is perfect for developers who love Sinatra’s lightweight nature but need more functionality and organization to tackle feature-packed applications.\u003c/p>","@type":"Answer"}},{"name":"How do I mount multiple sub-apps in one Padrino project?","@type":"Question","acceptedAnswer":{"text":"\u003cp>To include multiple sub-apps in a Padrino project, you can use the \u003ccode>mount\u003c/code> method within your main application. Here's a quick example:\u003c/p> \u003cpre>\u003ccode class=\"language-ruby\">Padrino.mount('SubApp1').to('/subapp1') Padrino.mount('SubApp2').to('/subapp2') \u003c/code>\u003c/pre> \u003cp>Each sub-app should be set up as an independent Padrino application. The main app will handle routing by directing requests to the appropriate sub-app based on the URL prefix defined in the \u003ccode>to()\u003c/code> method.\u003c/p>","@type":"Answer"}},{"name":"Why do I need to add Puma, Thin, or WEBrick manually?","@type":"Question","acceptedAnswer":{"text":"\u003cp>When using Padrino, you’ll need to manually add a web server like \u003cstrong>Puma\u003c/strong>, \u003cstrong>Thin\u003c/strong>, or \u003cstrong>WEBrick\u003c/strong> to your application. These servers aren’t bundled by default, so it’s up to you to install and configure one to ensure your app runs as expected.\u003c/p>","@type":"Answer"}}]}]}
```

