Hi im having some trouble with a system i am creating. I am attempting to make a CMS in rails. I am having a trouble with a certain aspect of this. Bear with me whilst i try to explain myself.

The first thing i have is a table of page contents this page content can contain any text, you can also place snippets. (Ive taken that term from radiant). So if you want a ceratin bit of code to appear you enter

Code:
<snippet:controller:action variable1 variable2>
so for example i have created a news plugin fro my system which would be called using

Code:
<snippet:news:small_news 5>
This code should render a list of latest news.

So i have the following file structure.

controllers
default_controller.html.rb
news_controller.html.rb
views
default
content_page.html.erb
news
_small_news.html.erb

What i am trying to do is on the content page it does a regular expression match for the snippet string and extracts the controller, action, and variables which i have managed to do successfully. It will then run the controller/action. This controller/action will then create the component and send that back as a string.

default_controller.rb
Code:
def content_page
   if @content
      @page_content = @content.content;
   end
		
   while @page_content =~ /\<snippet:(.*):([^ ]*) *(.*)\>/
      @variables = $3.to_i;
      @object = NewsController.new()
      @news_snippets = @object.send 'small_news', @variables
      @page_content = @page_content.gsub(/\<snippet:(.*):([^ ]*) *(.*)\>/,  'test')
   end
end
At the moment the calls to the necesary external functions are hardcoded but this will change.

news_controller.rb
Code:
def small_news(limit=5)
   render_to_string :partial => 'news/small_news'
end
When this is run i get an error in the small_news definition.

Code:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.body=
This is the Trace:
Code:
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:968:in `erase_render_results'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:932:in `render_to_string'
app/controllers/news_controller.rb:9:in `small_news'
app/controllers/default_controller.rb:15:in `content_page'
What would be causing the error if i place the render_to_string within the default_controller/content_page definition it will render fine.

I have created a normal controller and view for a page within the news controller which render sthe same template to a variable and this works fine. It is only when i call the render_to_string from another controller?

This may not be the way to go with this but i wanted to create 'plugins' for my cms system which need to be external to everything else on the system so this was in my mind the best way to do it?