<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: ActsAsRenderer Brings Output to Models</title>
	<atom:link href="http://davetroy.com/posts/actsasrenderer-brings-output-to-models/feed" rel="self" type="application/rss+xml" />
	<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models</link>
	<description>Design, Entrepreneurship, Economics and Software</description>
	<lastBuildDate>Sun, 29 Jan 2012 14:43:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Mr. Weir</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-202</link>
		<dc:creator>Mr. Weir</dc:creator>
		<pubDate>Fri, 21 Nov 2008 06:04:40 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-202</guid>
		<description>Thank you very much for creating this.  It is a wonderful solution.</description>
		<content:encoded><![CDATA[<p>Thank you very much for creating this.  It is a wonderful solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: walt D</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-67</link>
		<dc:creator>walt D</dc:creator>
		<pubDate>Sun, 13 Apr 2008 12:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-67</guid>
		<description>Well - so I tried using your plugin - and failed miserably at doing so :(&lt;br/&gt;&lt;br/&gt;I&#039;m sure I&#039;m to blame, myself - but perhaps you can point the finger more precisely at me :)&lt;br/&gt;&lt;br/&gt;I added acts_as_renderer to my class Invoice &lt; ActiveRecord::Base and threw a &lt;b&gt;def build_invoice&lt;/b&gt; in there too.&lt;br/&gt;&lt;br/&gt;When I tried using it - something in your plugin/init.rb blows up - and the result is that I get an error page when I try accessing any form new or form/edit in my app, with a note telling me that a copy of an ApplicationHelper was removed but still active.&lt;br/&gt;&lt;br/&gt;I have a class ExtendedLayoutFormBuilder &lt; ActionView::Helpers::FormBuilder &lt;br/&gt;&lt;br/&gt;and that apparently gets hurt pretty bad by your plugin :(&lt;br/&gt;&lt;br/&gt;I&#039;m not sure what your plugin actually do, but somehow it breaks my extendedformbuilder&lt;br/&gt;&lt;br/&gt;As I set out - I&#039;m sure that I&#039;m to blame, but all my layoutbuilder do is:&lt;br/&gt;&lt;br/&gt;&lt;i&gt;&lt;br/&gt;  helpers = field_helpers + &lt;br/&gt;    %w(date_select datetime_select time_select collection_select) - &lt;br/&gt;    %w(label fields_for) &lt;br/&gt;&lt;br/&gt;  helpers.each do &#124;name&#124; &lt;br/&gt;    define_method name do &#124;field, *args&#124; &lt;br/&gt;      options = args.detect {&#124;argument&#124; argument.is_a?(Hash)} &#124;&#124; {} &lt;br/&gt;      build_shell(field, options) do &lt;br/&gt;        super &lt;br/&gt;      end &lt;br/&gt;    end &lt;br/&gt;  end &lt;br/&gt;&lt;br/&gt;  def build_shell(field, options) &lt;br/&gt;    @template.capture do &lt;br/&gt;      locals = { &lt;br/&gt;        :element =&gt; yield, &lt;br/&gt;        :label =&gt; label(field, (options[:label] &#124;&#124; &quot;&quot;) ),&lt;br/&gt;        :lbl =&gt; options[:label],&lt;br/&gt;        :frmless =&gt; options[:frmless],# &#124;&#124; nil,&lt;br/&gt;        :required =&gt; options[:required],# &#124;&#124; nil,&lt;br/&gt;        :css =&gt; options[:class],&lt;br/&gt;        :instruction =&gt; options[:instruction]# &#124;&#124; nil &lt;br/&gt;      } &lt;br/&gt;      if has_errors_on?(field) &lt;br/&gt;        locals.merge!(:error =&gt; error_message(field, options)) &lt;br/&gt;        @template.render :partial =&gt; &#039;forms/field_with_errors&#039;, &lt;br/&gt;                         :locals =&gt; locals &lt;br/&gt;      else &lt;br/&gt;        @template.render :partial =&gt; &#039;forms/field&#039;, &lt;br/&gt;                         :locals =&gt; locals &lt;br/&gt;      end &lt;br/&gt;    end &lt;br/&gt;  end &lt;br/&gt;&lt;br/&gt;  def error_message(field, options) &lt;br/&gt;    if has_errors_on?(field) &lt;br/&gt;      errors = object.errors.on(field) &lt;br/&gt;      errors.is_a?(Array) ? errors.to_sentence : errors &lt;br/&gt;    else &lt;br/&gt;      &#039;&#039; &lt;br/&gt;    end &lt;br/&gt;  end &lt;br/&gt;&lt;br/&gt;  def has_errors_on?(field) &lt;br/&gt;    !(object.nil? &#124;&#124; object.errors.on(field).blank?) &lt;br/&gt;  end&lt;br/&gt;&lt;/i&gt;</description>
		<content:encoded><![CDATA[<p>Well &#8211; so I tried using your plugin &#8211; and failed miserably at doing so <img src='http://davetroy.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>I&#8217;m sure I&#8217;m to blame, myself &#8211; but perhaps you can point the finger more precisely at me <img src='http://davetroy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I added acts_as_renderer to my class Invoice < ActiveRecord::Base and threw a <b>def build_invoice in there too.</p>
<p>When I tried using it &#8211; something in your plugin/init.rb blows up &#8211; and the result is that I get an error page when I try accessing any form new or form/edit in my app, with a note telling me that a copy of an ApplicationHelper was removed but still active.</p>
<p>I have a class ExtendedLayoutFormBuilder < ActionView::Helpers::FormBuilder <br/><br />and that apparently gets hurt pretty bad by your plugin <img src='http://davetroy.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>I&#8217;m not sure what your plugin actually do, but somehow it breaks my extendedformbuilder</p>
<p>As I set out &#8211; I&#8217;m sure that I&#8217;m to blame, but all my layoutbuilder do is:</p>
<p><i><br />  helpers = field_helpers + <br />    %w(date_select datetime_select time_select collection_select) &#8211; <br />    %w(label fields_for) </p>
<p>  helpers.each do |name| <br />    define_method name do |field, *args| <br />      options = args.detect {|argument| argument.is_a?(Hash)} || {} <br />      build_shell(field, options) do <br />        super <br />      end <br />    end <br />  end </p>
<p>  def build_shell(field, options) <br />    @template.capture do <br />      locals = { <br />        :element => yield, <br />        :label => label(field, (options[:label] || &#8220;&#8221;) ),<br />        :lbl => options[:label],<br />        :frmless => options[:frmless],# || nil,<br />        :required => options[:required],# || nil,<br />        :css => options[:class],<br />        :instruction => options[:instruction]# || nil <br />      } <br />      if has_errors_on?(field) <br />        locals.merge!(:error => error_message(field, options)) <br />        @template.render :partial => &#8216;forms/field_with_errors&#8217;, <br />                         :locals => locals <br />      else <br />        @template.render :partial => &#8216;forms/field&#8217;, <br />                         :locals => locals <br />      end <br />    end <br />  end </p>
<p>  def error_message(field, options) <br />    if has_errors_on?(field) <br />      errors = object.errors.on(field) <br />      errors.is_a?(Array) ? errors.to_sentence : errors <br />    else <br />      &#8221; <br />    end <br />  end </p>
<p>  def has_errors_on?(field) <br />    !(object.nil? || object.errors.on(field).blank?) <br />  end<br /></i></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: walt D</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-66</link>
		<dc:creator>walt D</dc:creator>
		<pubDate>Sun, 13 Apr 2008 11:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-66</guid>
		<description>Hi Dave,&lt;br/&gt;&lt;br/&gt;I&#039;m trying to figure whether this plugin will help me do this:&lt;br/&gt;&lt;br/&gt;I have an Invoices controller which renders a &quot;show.html.erb&quot; template (without layouts) - and I&#039;d like this to go into a file instead of being presented to the user.&lt;br/&gt;&lt;br/&gt;Right now I call a system command which &lt;i&gt;curl -G http://localhost:3000/invoices/1 -o invoice_1.html&lt;/i&gt; - but my provider will not let me do this :(&lt;br/&gt;&lt;br/&gt;Can I use this plugin - or do you know of some other way?&lt;br/&gt;&lt;br/&gt;best regards,&lt;br/&gt;Walther</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>I&#8217;m trying to figure whether this plugin will help me do this:</p>
<p>I have an Invoices controller which renders a &#8220;show.html.erb&#8221; template (without layouts) &#8211; and I&#8217;d like this to go into a file instead of being presented to the user.</p>
<p>Right now I call a system command which <i>curl -G <a href="http://localhost:3000/invoices/1" rel="nofollow">http://localhost:3000/invoices/1</a> -o invoice_1.html</i> &#8211; but my provider will not let me do this <img src='http://davetroy.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Can I use this plugin &#8211; or do you know of some other way?</p>
<p>best regards,<br />Walther</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Troy</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-63</link>
		<dc:creator>Dave Troy</dc:creator>
		<pubDate>Fri, 14 Mar 2008 15:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-63</guid>
		<description>Rob,  your fix is exactly what I would suggest.  I debated whether to base the viewer on ActionController::Base or ApplicationController, and the helper support is the obvious reason to go for the latter.  I was trying to keep it as simple as possible.&lt;br/&gt;&lt;br/&gt;I will put that into the next revision.  Meantime you can just make the change as suggested.  Thanks for the feedback everyone.</description>
		<content:encoded><![CDATA[<p>Rob,  your fix is exactly what I would suggest.  I debated whether to base the viewer on ActionController::Base or ApplicationController, and the helper support is the obvious reason to go for the latter.  I was trying to keep it as simple as possible.</p>
<p>I will put that into the next revision.  Meantime you can just make the change as suggested.  Thanks for the feedback everyone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Holland</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-62</link>
		<dc:creator>Rob Holland</dc:creator>
		<pubDate>Fri, 14 Mar 2008 10:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-62</guid>
		<description>Changing the self.render_string function to that listed below makes sure that the application helper is also loaded:&lt;br/&gt;&lt;br/&gt;viewer = Class.new(ApplicationController)&lt;br/&gt;view = Class.new(ActionView::Base)&lt;br/&gt;view.send(:include, viewer.master_helper_module)&lt;br/&gt;path = ActionController::Base.view_paths rescue ActionController::Base.view_root&lt;br/&gt;view.new(path, assigns, viewer).render(template)</description>
		<content:encoded><![CDATA[<p>Changing the self.render_string function to that listed below makes sure that the application helper is also loaded:</p>
<p>viewer = Class.new(ApplicationController)<br />view = Class.new(ActionView::Base)<br />view.send(:include, viewer.master_helper_module)<br />path = ActionController::Base.view_paths rescue ActionController::Base.view_root<br />view.new(path, assigns, viewer).render(template)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tigger</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-61</link>
		<dc:creator>tigger</dc:creator>
		<pubDate>Thu, 13 Mar 2008 12:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-61</guid>
		<description>Thanks for taking the time to do this cleanly, it&#039;s just what we&#039;ve been trying to do.&lt;br/&gt;&lt;br/&gt;I&#039;ve a small issue with using it though, which is that the application_helper doesn&#039;t seem to have been loaded and I can&#039;t quite figure out how to get that working.&lt;br/&gt;&lt;br/&gt;Any ideas?</description>
		<content:encoded><![CDATA[<p>Thanks for taking the time to do this cleanly, it&#8217;s just what we&#8217;ve been trying to do.</p>
<p>I&#8217;ve a small issue with using it though, which is that the application_helper doesn&#8217;t seem to have been loaded and I can&#8217;t quite figure out how to get that working.</p>
<p>Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Troy</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-60</link>
		<dc:creator>Dave Troy</dc:creator>
		<pubDate>Wed, 12 Mar 2008 02:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-60</guid>
		<description>This is an interesting problem.  Not sure exactly what you&#039;re trying to accomplish in practice, but perhaps the constants could be put into environment.rb?&lt;br/&gt;&lt;br/&gt;The acts_as_renderer plugin only subclasses ActionController:Base and should not need anything too peculiar.  If you can tell me a bit more about specifically what you think you&#039;re adding that&#039;s breaking this (and where you&#039;re adding it) I might be able to come up with a tidy fix.&lt;br/&gt;&lt;br/&gt;I&#039;ve used this to great ends this week!  I know I will be using this plugin myself for several projects in the future.</description>
		<content:encoded><![CDATA[<p>This is an interesting problem.  Not sure exactly what you&#8217;re trying to accomplish in practice, but perhaps the constants could be put into environment.rb?</p>
<p>The acts_as_renderer plugin only subclasses ActionController:Base and should not need anything too peculiar.  If you can tell me a bit more about specifically what you think you&#8217;re adding that&#8217;s breaking this (and where you&#8217;re adding it) I might be able to come up with a tidy fix.</p>
<p>I&#8217;ve used this to great ends this week!  I know I will be using this plugin myself for several projects in the future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dasil003</title>
		<link>http://davetroy.com/posts/actsasrenderer-brings-output-to-models#comment-58</link>
		<dc:creator>dasil003</dc:creator>
		<pubDate>Mon, 10 Mar 2008 23:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://dave.popvox.com/?p=16#comment-58</guid>
		<description>What, no comments?  This plugin is awesome!&lt;br/&gt;&lt;br/&gt;Glad you made the MVC comment, because it&#039;s easy to dismiss the need for this.  But for those of us who know what we&#039;re doing this is indispensable.&lt;br/&gt;&lt;br/&gt;Rails controllers and views are made primarily for rendering to a browser, but HTML and other output often times needs to go other places.  The alternatives to this plugin are HTML in models or rolling your own template system, either way pretty ugly.&lt;br/&gt;&lt;br/&gt;Anyway, one comment on this plugin.  We just installed it into our current project and had one problem.  We are using some constants in our controllers, and since plugins are loaded before initializers, we get LoadErrors.  Our solution is to put the plugin in lib/ and load it manually.  Any ideas for a cleaner solution?</description>
		<content:encoded><![CDATA[<p>What, no comments?  This plugin is awesome!</p>
<p>Glad you made the MVC comment, because it&#8217;s easy to dismiss the need for this.  But for those of us who know what we&#8217;re doing this is indispensable.</p>
<p>Rails controllers and views are made primarily for rendering to a browser, but HTML and other output often times needs to go other places.  The alternatives to this plugin are HTML in models or rolling your own template system, either way pretty ugly.</p>
<p>Anyway, one comment on this plugin.  We just installed it into our current project and had one problem.  We are using some constants in our controllers, and since plugins are loaded before initializers, we get LoadErrors.  Our solution is to put the plugin in lib/ and load it manually.  Any ideas for a cleaner solution?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

