Padrino 0.17.0 release

Padrino 0.17.0 is out. It runs on Ruby 4.0 and HAML 6 and 7, adds Falcon, Vite and Tailwind CSS to the generators, and fixes a long list of bugs in the generators, the mailer, the reloader and the ActiveRecord rake tasks. It also removes generators for ORMs that are no longer maintained, so read the breaking changes below before you upgrade.

Thanks to @achiurizo, @osbre, @genkami, @matsubara0507 and @Shaisolaris for their work on this release. The full list is in CHANGES.rdoc.

Padrino 0.16.2 is out too. It brings HAML 6 and 7 and Ruby 4.0 to apps that stay on 0.16 for now, such as Middleman sites.

Highlights

  • Ruby 4.0 and HAML 6/7. Padrino also runs with --enable-frozen-string-literal.
  • New generator options: --server=falcon, --script=vite and --stylesheet=tailwind.
  • Faster boot outside development: files are only tracked for reloading in development.
  • Mailers are safe to deliver concurrently, and Padrino's view helpers (link_to, form_for, partial) work in mailer templates.
  • ActiveRecord 7.1 to 8.1 rake tasks work again, and the ActiveRecord model and migration generators take :index and :uniq (email:string:uniq).
  • Generated projects set SameSite=Lax on the session cookie and skip CSRF checks in the test environment.
  • jQuery 3.7.1: --script jquery and padrino g admin copy jQuery 3.7.1 (was 1.9 and 1.11), with an updated UJS adapter.
  • Hardening: static files are served only from the public folder; link_to and form_tag drop javascript: and other unsafe URL schemes; admin access control compares decoded paths.

Breaking changes

  • Removed ORMs. The DataMapper, MongoMapper, CouchRest, Ripple and Mongomatic generators and rake tasks are gone, as are the Compass and ExtCore components. Existing apps keep running, but padrino g model and padrino g migration stop working in projects that use them.
  • -s means --script again. --server no longer has a short alias: use --server=puma.
  • Generators exit with status 1 when they fail, instead of 0.
  • Reloading outside development (enable :reload in staging, for example) needs Padrino::Reloader.enabled = true before Padrino.load!.
  • Admin access control matches string paths as literal prefixes on path boundaries. allow '/posts' covers /posts, /posts/... and /posts.json, but no longer /posts_admin, and regular-expression syntax inside a string is no longer interpreted. A Regexp, such as allow %r{\A/posts/\d+}, still matches as a pattern.
  • Links with other schemes. link_to and form_tag render # for any scheme other than http, https, mailto, tel and ftp, such as sms: or a custom app scheme.
  • CGI. Padrino no longer loads the whole CGI library. On Ruby before 4.0, add require 'cgi' if your app uses CGI::Cookie, CGI.parse or similar.
  • Server auto-detection prefers Falcon over the other servers when neither Thin nor Puma is installed.

Upgrading from 0.16

  1. In your Gemfile, set gem 'padrino', '~> 0.17.0' (or the same version for each padrino-* gem you list), then run bundle update padrino.
  2. If you reload code outside development, add Padrino::Reloader.enabled = true before Padrino.load! in config/boot.rb.
  3. If you use admin access control, check each allow and protect path: list paths such as /posts_admin explicitly, and turn any string that relies on regular-expression syntax into a Regexp.
  4. Write links with custom URL schemes as plain <a href="..."> tags instead of link_to.
  5. On Ruby before 4.0, add require 'cgi' if you use CGI beyond escaping. On Ruby 4.0, add gem 'irb' to your Gemfile to use padrino console, since irb is no longer a default gem there.
  6. In scripts, use --server=NAME instead of -s NAME, and expect a non-zero exit when a generator fails.
  7. Generated files are yours, so existing projects keep their jQuery 1.x. To update, copy js/jquery.js and ujs/jquery.js from padrino-static over public/javascripts/jquery.js and public/javascripts/jquery-ujs.js, and for the admin, copy jquery-3.7.1.min.js into public/admin/javascripts and change the javascript_include_tag line in admin/views/layouts/application and admin/views/sessions/new to it. Re-running padrino g admin also works, but answer n for admin/app.rb and any file you changed: it overwrites them. On custom admin pages, give Bootstrap 3.1's collapse, tab, modal and alert data attributes a data-target instead of a bare href="#".
  8. Run your test suite and boot the app.

Ruby 2.7.8 or later, Sinatra 4 and Rack 3 are still required, as in 0.16.

comments powered by Disqus

Type to search the guides.