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