Edit phrases inline for your Ruby on Rails applications!
Ruby CSS HTML JavaScript
Latest commit 69997dc Oct 24, 2016 @anacar anacar committed on GitHub Update README.md
Failed to load latest commit information.
app Changed this: query.order("#{query.table_name}.[key]") to this: query… Sep 30, 2015
config Change hashrockets to new hash syntax. Jul 29, 2014
spec Change hashrockets to new hash syntax in specs. Jul 29, 2014
.gitignore Removed all the dummy cached logs from tracking. May 8, 2014
.travis.yml Test w/ ruby 2.2 and rails 4.2.0 Jan 7, 2015
4.0.0_changes.md Create 4.0.0_changes.md Sep 21, 2014
CHANGELOG.md Bump to version 3.2.0 Oct 2, 2015
Gemfile Require only haml, not haml-rails. Jan 7, 2015
README.md Update README.md Oct 24, 2016
Rakefile Change hashrockets to new hash syntax. Jul 29, 2014
phrasing.gemspec Require only haml, not haml-rails. Jan 7, 2015



Build Status

Phrasing is a gem for live editing phrases (copy) on websites.

Phrasing is currently iterating over release candidates for a major update: 4.0. The Readme for those versions can be found here


Include the gem in your Gemfile

gem "phrasing"

Bundle the Gemfile

bundle install

Run the install script which will create a migration file and a config file.

rake phrasing:install

Migrate your database

rake db:migrate


The rake task will also generate phrasing_helper.rb in your app/helpers folder. Here you will need to implement the can_edit_phrases? method. Use this to hook-up your existing user authentication system to work with Phrasing.

For example:

module PhrasingHelper

  def can_edit_phrases?


Include the phrasing html initializer at the top of your application layout file.

= render 'phrasing/initializer'

Include the required javascript file:

//= require phrasing

Include the required stylesheet file:

*= require phrasing

How to use phrasing?

You can start adding new phrases by simply adding them in your view file:

= phrase('my-first-phrase')

Aside from editing phrases (basically, Rails translations) you can also edit model attributes inline. Use the same phrase method, with the first attribute being the record in question, and the second one the attribute you wish to make editable:

= phrase(@post, :title)

In the above example, @post is the record with a title attribute.


Since Phrasing can be used to update any attribute in any table (using the model_phrase method), special care must be taken into consideration from a security standpoint.

By default, Phrasing doesn't allow updating of any attribute apart from PhrasingPhrase.value. To be able to work with other attributes, you need to whitelist them.

In the config/initializers/phrasing.rb file you can whitelist your model attributes like this:

Phrasing.white_list = ["Post.title", "Post.body"]

or you can whitelist all of them (not recommended) with:

Phrasing.allow_update_on_all_models_and_attributes = true

Upgrading from version 2.x to 3.x

In versions 3.0.0 and above we have added the Phrasing Versioning System which requires an additional table, so if you are upgrading to a 3.x release, run rake phrasing:install to get the additional migration file, then run rake db:migrate.


If you're experiencing problems with Rails apps using Turbolinks, include the jQuery-turbolinks gem in your application and simply require it in the following order:

//= require jquery
//= require jquery.turbolinks
//= require phrasing
//= require turbolinks

Phrasing Appearance

The phrase view helper can take the options hash as the last parameter. Features:

url: custom_url # point Phrasing to other actions in other controllers
inverse: true # change the hovered background and underline colors to better fit darker backgrounds
class: custom_class # add custom CSS classes to your phrases to change the appearance of phrases in your application 
interpolation: { %min: 10 } # add variables to your translations just like w/ I18n
scope: 'homepage.footer' # add scopes just like you would w/ I18.n. If the first argument is 'test', than the key would be 'homepage.footer.test'


Phrasing is maintained and sponsored by Infinum.

Phrasing leverages parts of Copycat and ZenPen.


Phrasing is Copyright © 2013 Infinum. It is free software, and may be redistributed under the terms specified in the LICENSE file.