Ruby on Rails Plugins
form_helper_css
This plugin enhances the default tag helpers to automatically add CSS classes to form elements. It’s similar to the enhanced_form_tag_helper plugin, but takes a different approach by directly intercepting the tag and content_tag methods, and should therefore work in all situations where form elements are created, especially the FormHelper and more exotic ones like button_to.
The following elements are enhanced:
<input>tags get their type as class name- submit buttons additionally get the class name button
- password fields additionally get the class name text
<textarea>tags get the class name text<select>tags get the class name select<button>tags get the class name button
If any helper options already specify a class, nothing will be changed. If you don’t want a class to be added, pass :class => nil.
Installation
script/plugin install -x http://dev.diarrhea.ch/svn/rails_plugins/trunk/form_helper_css
redcloth_template
This plugin registers a template handler for *.red files, which will be run through ERB and RedCloth, and enables you to use Textile syntax directly in your views.
Note: this plugin requires at least RedCloth 4.0 (aka "SuperRedCloth").
Installation
script/plugin install -x http://dev.diarrhea.ch/svn/rails_plugins/trunk/redcloth_template
auto_convert_fields
This plugin lets you define model fields which should be automatically converted with helpers from the TextHelper module, or a custom block. It works by redefining the field= method, so it applies immediately. If you already have a custom setter, it will be aliased and called after the conversion. You can also use the old (or default) setter explicitly by calling field_without_auto_convert=.
Usage
Use the class method auto_convert to specify fields, and pass symbols for the helpers in the :with option:
class MyModel < ActiveRecord::Base auto_convert :name, :text, :with => :strip_tags end
You can specify multiple helpers by passing an array. The helpers will be run in the order they’re specified in:
class MyModel < ActiveRecord::Base auto_convert :name, :text, :with => [ :strip_tags, :simple_format ] end
For more complex cases, pass a block which will be given the value. The helpers are also available in the context of the block:
class MyModel < ActiveRecord::Base auto_convert :name, :text do |value| strip_tags(value).strip.gsub(/[^\w ]/, '') end end
Installation
script/plugin install -x http://dev.diarrhea.ch/svn/rails_plugins/trunk/auto_convert_fields