<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John Yerhot - Weblog &#187; Helpers</title>
	<atom:link href="http://www.johnyerhot.com/tag/helpers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johnyerhot.com</link>
	<description>moof</description>
	<lastBuildDate>Mon, 16 Aug 2010 22:11:50 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails: Using Helpers in Your Controller.</title>
		<link>http://www.johnyerhot.com/2008/01/10/rails-using-helpers-in-you-controller/</link>
		<comments>http://www.johnyerhot.com/2008/01/10/rails-using-helpers-in-you-controller/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 15:40:15 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[Controller]]></category>
		<category><![CDATA[Helpers]]></category>
		<category><![CDATA[pdf-writer]]></category>

		<guid isPermaLink="false">http://www.johnyerhot.com/2008/01/10/rails-using-helpers-in-you-controller/</guid>
		<description><![CDATA[This morning there was a guy in the rails IRC room asking about using helpers in his controller and I recently wrote an app that used the great pdf-writer gem to generate some pdfs and used helpers in the controller for formatting in the pdf.  If you are going to generate very complicated pdfs, [...]]]></description>
			<content:encoded><![CDATA[<p>This morning there was a guy in the rails IRC room asking about using helpers in his controller and I recently wrote an app that used the great <a href="http://ruby-pdf.rubyforge.org/pdf-writer/" target="_blank">pdf-writer</a> gem to generate some pdfs and used helpers in the controller for formatting in the pdf.  If you are going to generate very complicated pdfs, its best not to put your pdf formatting code directly in the controller, but if you need just a real quick pdf generated, this works great.</p>
<p>First, create a new class in your application controller:<br />
<code><br />
class Helper<br />
include Singleton<br />
include ActionView::Helpers::PdfHelper #or whatever helpers you want<br />
end<br />
</code><br />
I wanted to use my pdf_helpers<br />
..and then:<br />
<code><br />
def pdf_helpers<br />
Helper.instance<br />
end</code><br />
Will create an instance of your new class.</p>
<p>Now, go to your pdf controller (or whatever) and simply:<br />
<code><br />
pdf.text pdf_helpers.my_crazy_helper(@foo.bar)<br />
</code></p>
<p>The pdf.text part is not the important part, thats just for pdf-writer, but what is is using &#8220;pdf_helpers.your_helper&#8221; to create a new instance of the helper class which will allow you to use that helper.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johnyerhot.com/2008/01/10/rails-using-helpers-in-you-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
