Rail 3 custom renderer: where do put this code?

Posted by Derick Bailey on Stack Overflow See other posts from Stack Overflow or by Derick Bailey
Published on 2011-02-16T15:22:05Z Indexed on 2011/02/16 15:25 UTC
Read the original article Hit count: 301

I'm following along with Yehuda's example on how to build a custom renderer for Rails 3, according to this post: http://www.engineyard.com/blog/2010/render-options-in-rails-3/

I've got my code working, but I'm having a hard time figuring out where this code should live. Right now, I've got my code stuck right inside of my controller file. Doing this, everything works. When I move the code to the lib folder, though, I have explicitly 'require' my file in the controller that needs the renderer or it won't work. Yes, the file gets loaded when it sits in the lib folder, automatically. but the code to add the renderer isn't working for some reason, until I do a require on it.

where should I put my code to add the renderer and mime type, so that rails 3 will pick it up and register it for me, without me having to manually require the file in my controller?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby