Extending Padrino Projects
As you being building real projects with Padrino, you will quickly require additional functionality not built into Padrino itself. Thankfully finding and using modular libraries that add additional functionality to your Sinatra and Padrino applications is quite painless.
Managing Dependencies with Bundler
In order to manage dependencies for a project, Padrino relies on another gem
called Bundler. A default Padrino
looks akin to this:
# Gemfile source 'https://rubygems.org' # Project requirements gem 'rake' # ...more gems... # Padrino Stable Gem gem 'padrino', '0.13.1'
All dependencies and libraries required for your project should be declared in
Gemfile which is generated automatically with every Padrino
application. Once the dependencies have been declared, simply run Bundler's
This will resolve and install all the required libraries. Check out the Bundler documentation for more details about how this works.
The best extensions to look for are those that have already been included as "recipes" in our padrino-recipes repository. Any recipe included there represents a single command installation of the specified functionality. For instance, suppose you want to setup pagination in your application for a resource. Installing the will_paginate gem is as simple as applying the recipe:
$ padrino g plugin will_paginate
This will install that gem into your project (and Gemfile) automatically.
If you can't find a recipe in the padrino-recipes repository, then be sure to search for Rack middlewares or Sinatra compatible libraries to use in your app.
And, of course, never underestimate searching GitHub to find Rack or Sinatra compatible repositories. Any Rack/Sinatra/Padrino library will generally work seamlessly in Padrino projects. Consider adding a recipe for your favorite extensions!
last updated: 2018-07-12comments powered by Disqus