Thursday, 3 March 2016

Edit/Update dynamic data like best in place by Phrasing-

Installation

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

Setup

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?
    current_user.is_admin?
  end

end
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.


or Follow https://github.com/infinum/phrasing

No comments:

Post a Comment