Skip to content

Associate a js wysiwyg editor or markup language processor with a field or fields on a model. For Rails 3.1

License

Notifications You must be signed in to change notification settings

azimuth/editable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Editable

Associate a set of possible editors/markup language processors with a field or fields on a model. A helper
is provided for displaying the proper editor or a plain textarea (for markup languages).

Usage

Gemfile


  gem 'editable'

Rake:


  rake editable_engine:install:migrations
  rake db:migrate

Model:


  class BlogPost < ActiveRecord::Base
    acts_as_editable :body, :processor => :textile
  end

View:


  <%= form_for @post do |f| %>
    ...
    <%= raw editor(@post, :body, {:cols => 60, :rows => 20}) %>
    ...
  <% end %>

acts_as_editable(:field, :processor => :processor_name)

:field

This is the field to attach the editor (and source processing)

Options

editor(instance, :field, {option => value})

This creates a text box and attaches any associated javascript necessary for the current editor type for that field.

instance

This is an instance of ActiveRecord::Base that has acts_as_editable field(s)

:field

This is the field the editor is for.

Options

Options are turned into attributes on the created textarea

Current Editors/processors support

  1. Reverse – bare textarea, simple processor that reverses the string. used for the tests
  2. Textile – bare textarea, simple RedCloth processing of textile input.

issues/bugs/todo

  1. Need more tests
  2. Needs editor switching
  3. Needs more processors/editors integrated
  4. Needs better handling of multiple acts_as_editable fields, need to assign a processor to each field, rather than
    keeping a single processor for the entire model.
  5. We should be able to get a syntax aware textarea running for markdown/textile.

Submit other bugs, suggestions, feature requests, criticisms, kudos, etc to Issues

About

Associate a js wysiwyg editor or markup language processor with a field or fields on a model. For Rails 3.1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published