Permalink
Browse files

Add railtie to perform initialization when running under rails3

  • Loading branch information...
1 parent f9c1a8a commit f7ec01e16939cae0a250cab1b172c5902b02ee5e @yabawock yabawock committed with yabawock Apr 15, 2010
Showing with 16 additions and 0 deletions.
  1. +3 −0 CHANGELOG
  2. +1 −0 lib/formtastic.rb
  3. +12 −0 lib/formtastic/railtie.rb
View
@@ -1,3 +1,6 @@
+(HEAD)
+* Added railtie to perform initialization tasks after the rails framework is available (rails3)
+
0.9.8
* Deprecated :selected/:checked options, see http://wiki.github.com/justinfrench/formtastic/deprecation-of-selected-option
View
@@ -1,5 +1,6 @@
# coding: utf-8
require File.join(File.dirname(__FILE__), *%w[formtastic i18n])
+require File.join(File.dirname(__FILE__), *%w[formtastic railtie]) if defined?(::Rails::Railtie)
module Formtastic #:nodoc:
@@ -0,0 +1,12 @@
+require 'formtastic'
+require 'formtastic/layout_helper'
+require 'rails'
+
+module Formtastic
+ class Railtie < Rails::Railtie
+ initializer :after_initialize do
+ ActionView::Base.send :include, Formtastic::SemanticFormHelper
+ ActionView::Base.send(:include, Formtastic::LayoutHelper)
+ end
+ end
+end

0 comments on commit f7ec01e

Please sign in to comment.