Socket
Book a DemoInstallSign in
Socket

filepress

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filepress

0.2.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Filepress

Filepress is a minimal Rails plugin that offers the best of both worlds for content management:

  • Write and version control your content in Markdown (or a similar format)
  • Sync it seamlessly to ActiveRecord models so you can harness the full power of a Rails backend.

Ideal for blogs, documentation, or any content-driven Rails app where you want the flexibility of flat files and the structure of a database.

Getting Started

  • Install the gem

Add it to your Gemfile:

gem "filepress"

Then run:

bundle install
  • Create a model to represent your content

Be sure to include a field that can serve as a unique identifier (e.g. slug):

rails g model Post title:string slug:string body:text
  • Enable Filepress for your model

Use the filepress method in your model class:

class Post < ApplicationRecord
    filepress
end
  • Add some content

Create Markdown files in app/content/posts. Each file should include frontmatter:

---
title: My First Post
slug: first
---

# Hello, this is my first post
  • Sync your content

Run the sync task to import your files into the database:

bin/rails filepress:sync

That’s it! You’re now free to query your content via ActiveRecord like any other model. Filepress doesn't dictate how you render the body—use a Markdown parser like Kramdown, Redcarpet, or similar.

How it works

Filepress reads your content files, extracts YAML frontmatter, and uses the values to populate or update model attributes. The rest of the file becomes the value of the body attribute (or another field, if configured).

Configuration

You can customize how Filepress behaves by passing options to filepress:

from: - Set a custom content directory

class Post
    filepress from: "app/my_custom_content_folder"
end

glob: - Use filetypes besides Markdown

class Post
    filepress glob: "*.html"
end

key: - Use a unique identifier other than slug

class Post
    filepress key: :name
end

body: - Set which attribute stores the main content

class Post
    filepress body: :content
end

destroy_stale: - Prevent deletion of records when files are removed

By default, Filepress deletes records when the corresponding file is removed. Disable this behavior with:

class Post
    filepress destroy_stale: false
end

Why Filepress?

Filepress is for you if:

  • You prefer writing content in files
  • You want the convenience of version control for content
  • And you still want powerful querying, associations, validations and all the other Rails goodness

FAQs

Package last updated on 25 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.