Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 17:59:00 GMT)

Extending ActionController

Posted by Sun, 05 Jun 2005 18:33:00 GMT

In my pursuit yesterday to make add the desired functionality to ActionController (render string to string), I talked to bitsweat about this and he suggested that I just extend the class in my rails app.

So, I created a file in lib, called action_controller_ext.rb (a shim as he referred to it) and put this in the file:

require 'action_controller'

class ActionController::Base

  def render_string_to_string(text = nil, type = "rhtml") #:doc:
    @template.render_template(type, text) 

Then in environment.rb, I changed:
require 'action_controller'
require 'action_controller_ext'

Now, I can move my clients app around dev/test/live servers and not need to modify the actual Rails source code. (still would be nice if it did that though)

Get help with your Rails project

comments powered by Disqus