render_to_string in lib class not working

Arwed picture Arwed · Apr 20, 2010 · Viewed 16.4k times · Source

I'm trying to use delayed_job to update a remote database via xml

In my lib folder I put a file with a class that should do a render_to_text with template.xml.builder, but I get:

undefined method `render_to_string' for #<SyncJob:0x7faf4e6c0480>...

What am I doing wrong?

Answer

ataer81 picture ataer81 · Sep 26, 2012
ac = ActionController::Base.new()
ac.render_to_string(:partial => '/path/to/your/template', :locals => {:varable => somevarable})