Editmode for Rails
Editmode frees up engineering time, unblocks designers and marketers, and helps software teams build better products faster, by allowing everyone on the team (not just the engineers) to make copy updates safely and in real time. You can think of it as "A CMS for product copy", or "If Contentful and i18n had a baby"
Let your design, product and engineering teams work in parallel - no more rigid hand-off process.
Inspired by i18n - just swap
<%= t('your_key') %>
for<%= e('your_key') %>
Safe, secure, and fast - used actively in large-scale production rails apps.
Changes reflect in real time - no re-deploy needed.
API first means no clunky Github workflows. So simple your mom could use it with no training.
Works with your existing codebase. Integration takes on average ~1 hour.
(Optional) Use the Magic Editor to let people make changes inline, on the page where they appear
(Optional) Use branches to run different versions of your content - for example a/b tests.
(Optional) Use our content API to store and serve more complex content e.g rich text transactional emails.
Installation
1. Add the gem to your Gemfile:
And run bundle install
.
2. Create an initializer with your project_id
Don't have a project id? Sign up for one here
This command produces an initializer file
By default Editmode will now include editmode.js in every page of your rails application, unless you disable auto-include.
3. (Rails 6 Only) Ensuring the Magic Editor works with Content Security Policy
Add "https://static.editmode.com" to
style_src
andscript_src
in your content security policy.Add "https://api.editmode.com" to
connect_src
in your content security policy.
Rendering Content
Editmode provides helper methods for use in your rails views and controllers.
Render the content of a chunk
Render an Editable chunk. (This will activate the inline Magic Editor)
Working with multiple projects in the same codebase
If you want to include content from a different project to the one you've specified in the initializer, you can pass the project id in to the view helper.
Content can also be accessed in Controllers
Directly get the value of a custom field
This works when a chunk is part of a collection.
Working with variables
Use collections for repeatable content
Access the current index from inside a collection block
Available from editmode-rails 1.50
Working with Image Transformation
Use transformation
attribute to perform real-time image transformations to deliver perfect images to the end-users.
Please see the complete list of transformation parameters.
Caching
In order to keep your application speedy, Editmode minimizes the amount of network calls it makes by caching content where it can.
What's cached
Any embedded content returned by the
e
,E
,f
, orF
viewhelpers.
Expiring the cache
The editmode gem exposes a cache expiration endpoint in your application at /editmode/clear_cache
.
GET
/editmode/clear_cache?identifier={chunk_id}
clears the cachefor a specific chunk.
GET
/editmode/clear_cache?full=1
clears the full Editmode cache.Editmode.js will automatically hit this endpoint when you update a chunk through your frontend.
You can configure cache expiration webhooks in Editmode.com to
ensure your application is notified when content changes happen on
Editmode.com
The cache expiration endpoint is currently not authenticated.
We are using a method called delete_matched
to purge your caches when a content gets updated, and this method isn't supported in memcached
. We highly recommend using redis_store
or file_store
.
Disabling editmode.js auto-include
To disable automatic insertion for a particular controller or action you can:
Last updated