Skip to content

Commit

Permalink
Rails 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieran Pilkington committed Apr 12, 2010
1 parent fa6d02f commit dc52a44
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions init.rb
@@ -1 +1,2 @@
require 'tiny_mce'
TinyMCE.initialize
20 changes: 15 additions & 5 deletions lib/tiny_mce.rb
Expand Up @@ -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')
Expand Down Expand Up @@ -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
13 changes: 13 additions & 0 deletions lib/tiny_mce/railtie.rb
@@ -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.