Permalink
Browse files

Rails 3 support

  • Loading branch information...
1 parent fa6d02f commit dc52a44380da041af4d32cff111b68f3fed9c96b Kieran Pilkington committed Apr 12, 2010
Showing with 29 additions and 5 deletions.
  1. +1 −0 init.rb
  2. +15 −5 lib/tiny_mce.rb
  3. +13 −0 lib/tiny_mce/railtie.rb
View
@@ -1 +1,2 @@
require 'tiny_mce'
+TinyMCE.initialize
View
@@ -6,6 +6,15 @@
require 'tiny_mce/helpers'
module TinyMCE
+ def self.initialize
+ return if @intialized
+ raise "ActionController is not available yet." unless defined?(ActionController)
+ ActionController::Base.send(:include, TinyMCE::Base)
+ ActionController::Base.send(:helper, TinyMCE::Helpers)
+ TinyMCE.install_or_update_tinymce
+ @intialized = true
+ end
+
def self.install_or_update_tinymce
require 'fileutils'
orig = File.join(File.dirname(__FILE__), 'tiny_mce', 'assets', 'tiny_mce')
@@ -65,9 +74,10 @@ module Base
end
end
-# Include the TinyMCE methods and TinyMCE Helpers into ActionController::Base
-if defined?(Rails) && defined?(ActionController)
- ActionController::Base.send(:include, TinyMCE::Base)
- ActionController::Base.send(:helper, TinyMCE::Helpers)
- TinyMCE.install_or_update_tinymce
+# Finally, lets include the TinyMCE base and helpers where
+# they need to go (support for Rails 2 and Rails 3)
+if defined?(Rails::Railtie)
+ require 'tiny_mce/railtie'
+else
+ TinyMCE.initialize
end
@@ -0,0 +1,13 @@
+if defined?(Rails::Railtie)
+ module TinyMCE
+ class Railtie < Rails::Railtie
+ rake_tasks do
+ load "tasks/tiny_mce.rake"
+ end
+
+ initializer :tiny_mce do
+ TinyMCE.initialize
+ end
+ end
+ end
+end

0 comments on commit dc52a44

Please sign in to comment.