Duncan Ponting
2006-Apr-20 16:23 UTC
[Rails] Using render_to_string in other custom classes
I have a project where I''m publishing files. Once when the user
clicks publish via a URL and one when an email is received that tells
the app they want to publish again. Because the publishing requires
templates I have them in there own views. The problem is when I want
to publish via email I don''t want to ask the controller to render the
views.
This is what I tried to do:
#/lib/myclass.rb
class foo
def build
@rts = ActionController::Base.new
file_x
file_y
end
def file_x
contents = @rts.render_to_string( path_to_my_template, self )
# and then I''d make the file etc
end
def file_y
contents = @rts.render_to_string( path_to_my_template, self )
# and then I''d make the file etc
end
end
the problem is that render_to_string is protected. Anyone know how I
can get around this?
--Duncan
Possibly Parallel Threads
- Re: Train wreck getting render_to_string to work from foreign controller [SOLVED]
- render_to_string() in a controller that isn''t default route?
- render_to_string inside method shared across several controllers
- rendering a partial inside another using render_to_string and (:formats) in controller
- Missing Template Error on render_to_string - Rails 3.2.2
