Read my latest article: Managing your Life the Agile Way in 2009 (posted Sun, 28 Dec 2008 21:20:00 GMT)

Extending ActionController

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

1 comment Latest by inung Tue, 08 May 2007 05:56:27 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:
    add_variables_to_assigns
    @template.render_template(type, text) 
  end

end
Then in environment.rb, I changed:
require 'action_controller'
to
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)

Subscribe to my RSS feed Enjoying the content? Be sure to subscribe to my RSS feed.
Comments
  1. Avatar
    inung Tue, 08 May 2007 05:56:27 GMT

    cooooll….:D

Share your thoughts... (really...I want to hear them)

Comments