Access a ActionControllers protected method from plugin?


#1

I can’t belive I fit that in as the subject!

I’m writing a plugin that will allow me to grab some text from a
database and call the render method from ActionController on part of the
text. I can’t seem to figure out how to access the render method of
ActionController::Base. I keep getting the “uninitialized constant
Execute” error. How can I do this? I’m I even barking up the right
tree? Here’s the relevent code

ActsAsBlog - used to convert redcloth,markdown,smarty to html. also

evals code and escpates html if needed
require ‘active_record’
require ‘action_controller’

class Execute < ActionController::Base
def self.execute_ruby_code( str )
logger.error(‘test’)
str = str.gsub(/<ruby>(.*?)</ruby>/) do |match|
match = self.render(:inline => $1, :type => ‘rhtml’)
logger.error(match)
end
str
end
end
module TextConversion
module Acts
module Blog
def self.included(base)
base.extend(ClassMethods)
end
def acts_as_blog
class_eval do
extend TextConversion::Acts::Blog::SingletonMethods
end
end
end
module SingletonMethods
def convert_to_html(txt, text_filter, restrictions = [])
txt = Execute.execute_ruby_code(txt)
end
return txt
end
end
end
end


#2

I’ve decided to go about it a different way. I’m just trying to access
the method directly from the plugin without inheriting from
ActionController. the ActionController::Base.render method fails now
because of this.

undefined method `render’ for ActionController::Base:Class

The method is actually in ActionController but it is marked as
protected, therefore I recieve the above error. How can I call this
method. How can I alias it as public for this plugin?

def execute_ruby_code( str )
logger.error(‘test’)
str = str.gsub(/<ruby>(.*?)</ruby>/) do |match|
match = ActionController::Base.render(:inline => $1, :type => ‘rhtml’)
logger.error(match)
end
str
end