Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

panoramic

> 编程语言
Open source

store rails views on database instead of filesystem

171 stars0 likes1 views
WebsiteGitHub

About

store rails views on database instead of filesystem

Panoramic

An ActionView::Resolver implementation to store rails views (layouts, templates and partials) on database. Simply put: what you can do with views on filesystem, can be done on database.

NOTE: at the moment, only ActiveRecord is supported, I've planned to add more ORMs (see Todo). If you can't wait, adding other ORMs should be very trivial.

Installation

Add the following line to Gemfile:

ruby
gem "panoramic"

Usage

Mandatory fields

Your model should have the following fields:

  • body (text): the source of template
  • path (string): where to find template (ex: layouts/application, you_controller/action, etc...)
  • locale (string): it depends from available locales in your app
  • handler (string): as locale field, it depends from avaiable handlers (erb, haml, etc...)
  • partial (boolean): determines if it's a partial or not (false by default)
  • format (string): A valid mimetype from Mime::SET.symbols

they're what the rails' Resolver API needs to lookup templates.

Model

A simple macro in model will activate your new Resolver. You can use a dedicated model to manage all the views in your app, or just for specific needs (ex: you want a custom template for some static pages, the other views will be fetched from filesystem).

ruby
class TemplateStorage  'custom_template'
  end

  def custom_template
    # use another model to fetch templates
    prepend_view_path AnotherModel.resolver
  end
end

And let's say you want to use database template resolving in all your controllers, but want to use panoramic only for certain paths (prefixed with X) you can use

ruby
class ApplicationController  'use_this_prefix_only')
end

This helps reducing the number of database requests, if Rails for example tries to look for layouts per controller.

ActionMailer

ruby
class MyEmail  model.path)
  end

Documentation

Need more help? Check out spec/dummy/, you'll find a dummy rails app I used to make tests ;-)

Testing

Enter Panoramic gem path, run bundle install to install development and test dependencies, then rake spec.

Todo

Long term

  • add generators

Contributing

Fork, make your changes, then send a pull request.

Credits

The main idea was heavily inspired from José Valim's awesome book Crafting Rails Applications. It helped me to better understand some Rails internals.

Issues· 10 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言