<?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: Custom Columns for the Ajax Scaffold Plugin</title>
	<atom:link href="http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/</link>
	<description>Life on and off the Rails</description>
	<lastBuildDate>Wed, 20 Aug 2008 17:47:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: andi</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-248</link>
		<dc:creator>andi</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-248</guid>
		<description>I just noticed that it stops working with single-table inheritance. the default order clause does not refer to the &#039;superclass table&#039; but to the &#039;plural_name&#039; property:

       Unknown column &#039;images.id&#039; in &#039;order clause&#039;: SELECT * FROM medias WHERE ( (medias.`type` = &#039;Image&#039; ) )  ORDER BY images.id asc  LIMIT 0, 25

as far as i found out, its around line 362 in lib/ajax_scaffold_plugin.rb, but I hesitate to change anything in the generated code there.

another thing: I use the globalize plugin, which stops working unless i remove all .rjs and .rhtml extensions from the action names in lib/ajax_scaffold_plugin.rb:

            return render#{suffix}_template(:action =&gt; &#039;edit.rjs&#039;) if request.xhr?

so far, nothing broke. I believe globalize uses some funky overrides with the template search path, it tries to detect language-specific template files (index_en.rhtml).

Other than that, fine work, that plugin!</description>
		<content:encoded><![CDATA[<p>I just noticed that it stops working with single-table inheritance. the default order clause does not refer to the &#8216;superclass table&#8217; but to the &#8216;plural_name&#8217; property:</p>
<p>       Unknown column &#8216;images.id&#8217; in &#8216;order clause&#8217;: SELECT * FROM medias WHERE ( (medias.`type` = &#8216;Image&#8217; ) )  ORDER BY images.id asc  LIMIT 0, 25</p>
<p>as far as i found out, its around line 362 in lib/ajax_scaffold_plugin.rb, but I hesitate to change anything in the generated code there.</p>
<p>another thing: I use the globalize plugin, which stops working unless i remove all .rjs and .rhtml extensions from the action names in lib/ajax_scaffold_plugin.rb:</p>
<p>            return render#{suffix}_template(:action =&gt; &#8216;edit.rjs&#8217;) if request.xhr?</p>
<p>so far, nothing broke. I believe globalize uses some funky overrides with the template search path, it tries to detect language-specific template files (index_en.rhtml).</p>
<p>Other than that, fine work, that plugin!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Rutherford</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-249</link>
		<dc:creator>Scott Rutherford</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-249</guid>
		<description>Hi Andi,

Thanks for the feedback. We haven&#039;t tried it yet with the Globalize plugin, but I will get it installed and check your fix works.

I have to admit single-table inheritance isn&#039;t something I have considered so far in developing the plugin. If I had, I would of realised it would not work with the current code. I will add this to the list of things to look at.

Thanks again
Scott.</description>
		<content:encoded><![CDATA[<p>Hi Andi,</p>
<p>Thanks for the feedback. We haven&#8217;t tried it yet with the Globalize plugin, but I will get it installed and check your fix works.</p>
<p>I have to admit single-table inheritance isn&#8217;t something I have considered so far in developing the plugin. If I had, I would of realised it would not work with the current code. I will add this to the list of things to look at.</p>
<p>Thanks again<br />
Scott.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JJ</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-250</link>
		<dc:creator>JJ</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-250</guid>
		<description>Hi - great plugin!

How would you go about adding a custom column to the form only for &#039;create&#039;?  I have a relationship between two models &#039;Program&#039; and &#039;Project&#039; - a Program has_many Projects, and a Project belongs_to a Program.

What I want is to have a drop-down when you are creating a Project with a list of Program names. The id of whatever Program you selected would then be populated in the program_id of the new Project.  You would then of course see the Program name in the table.  When editing, the field could be read-only (i.e. can&#039;t change programs once created).  So far I&#039;m using a single &#039;Admin&#039; controller.

thanks!</description>
		<content:encoded><![CDATA[<p>Hi &#8211; great plugin!</p>
<p>How would you go about adding a custom column to the form only for &#8216;create&#8217;?  I have a relationship between two models &#8216;Program&#8217; and &#8216;Project&#8217; &#8211; a Program has_many Projects, and a Project belongs_to a Program.</p>
<p>What I want is to have a drop-down when you are creating a Project with a list of Program names. The id of whatever Program you selected would then be populated in the program_id of the new Project.  You would then of course see the Program name in the table.  When editing, the field could be read-only (i.e. can&#8217;t change programs once created).  So far I&#8217;m using a single &#8216;Admin&#8217; controller.</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Rutherford</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-251</link>
		<dc:creator>Scott Rutherford</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-251</guid>
		<description>Hi JJ,

Both the create and edit actions render the _new_edit.rhtml template  and pass in a hash of options including :action. So the easiest thing to do would be customize (copy it from views/ajax_scaffold to views/project to get customization specific to the model) _new_edit.rhtml to do a check on @options[:action] and render a new template (say views/project/_create.rhtml) for the create action. You would also need to copy over _form.rhtml and edit that to get a read only value for the program field (maybe even call it _edit.rhtml!!)

So something like:

&lt;pre&gt;
&lt;% if @options[:action].match(&#039;create&#039;) %&gt;
  &lt;%= render :partial =&gt; scaffold_partial_path(&#039;create&#039;), :locals =&gt; { :scaffold_class =&gt; @scaffold_class, :scaffold_name =&gt; @scaffold_singular_name } %&gt;
&lt;% else %&gt;
  &lt;%= render :partial =&gt; scaffold_partial_path(&#039;edit&#039;), :locals =&gt; { :scaffold_class =&gt; @scaffold_class, :scaffold_name =&gt; @scaffold_singular_name } %&gt;
&lt;% end %&gt;
&lt;/pre&gt;

There is an example of a custom form in the comments of this &quot;post&quot;:http://blog.caronsoftware.com/articles/2006/09/02/getting-started-with-the-ajax-scaffold-plugin

Does that help?

Cheers
Scott.</description>
		<content:encoded><![CDATA[<p>Hi JJ,</p>
<p>Both the create and edit actions render the _new_edit.rhtml template  and pass in a hash of options including :action. So the easiest thing to do would be customize (copy it from views/ajax_scaffold to views/project to get customization specific to the model) _new_edit.rhtml to do a check on @options[:action] and render a new template (say views/project/_create.rhtml) for the create action. You would also need to copy over _form.rhtml and edit that to get a read only value for the program field (maybe even call it _edit.rhtml!!)</p>
<p>So something like:</p>
<p>&lt;pre&gt;<br />
&lt;% if @options[:action].match(&#8216;create&#8217;) %&gt;<br />
  &lt;%= render :partial =&gt; scaffold_partial_path(&#8216;create&#8217;), :locals =&gt; { :scaffold_class =&gt; @scaffold_class, :scaffold_name =&gt; @scaffold_singular_name } %&gt;<br />
&lt;% else %&gt;<br />
  &lt;%= render :partial =&gt; scaffold_partial_path(&#8216;edit&#8217;), :locals =&gt; { :scaffold_class =&gt; @scaffold_class, :scaffold_name =&gt; @scaffold_singular_name } %&gt;<br />
&lt;% end %&gt;<br />
&lt;/pre&gt;</p>
<p>There is an example of a custom form in the comments of this &quot;post&quot;:http://blog.caronsoftware.com/articles/2006/09/02/getting-started-with-the-ajax-scaffold-plugin</p>
<p>Does that help?</p>
<p>Cheers<br />
Scott.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ward</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-252</link>
		<dc:creator>Ward</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-252</guid>
		<description>Hi Scott,

Building on your explanation for JJ; it seems there&#039;s no elegant way to do for pages with many tables?

The naming convention used elsewhere doesn&#039;t seem to work - I had expected _new_edit_{prefix}.rhtml to do the trick, but putting that file in place makes the ajax calls die. Peeking in the code (lib/ajax_scaffold_plugin.rb line 253, 272) seems to confirm that this is not supported right now - or am I misreading the code?

Thanks,
Ward.</description>
		<content:encoded><![CDATA[<p>Hi Scott,</p>
<p>Building on your explanation for JJ; it seems there&#8217;s no elegant way to do for pages with many tables?</p>
<p>The naming convention used elsewhere doesn&#8217;t seem to work &#8211; I had expected _new_edit_{prefix}.rhtml to do the trick, but putting that file in place makes the ajax calls die. Peeking in the code (lib/ajax_scaffold_plugin.rb line 253, 272) seems to confirm that this is not supported right now &#8211; or am I misreading the code?</p>
<p>Thanks,<br />
Ward.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Rutherford</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-253</link>
		<dc:creator>Scott Rutherford</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-253</guid>
		<description>Hi Ward,

Do you mean many tables on the same page? If so it is outlined in this  &quot;post&quot;:http://blog.caronsoftware.com/articles/2006/09/02/getting-started-with-the-ajax-scaffold-plugin.

If you mean having nested tables representing a has_many relationship, not at the mo.

Scott.</description>
		<content:encoded><![CDATA[<p>Hi Ward,</p>
<p>Do you mean many tables on the same page? If so it is outlined in this  &quot;post&quot;:http://blog.caronsoftware.com/articles/2006/09/02/getting-started-with-the-ajax-scaffold-plugin.</p>
<p>If you mean having nested tables representing a has_many relationship, not at the mo.</p>
<p>Scott.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn Mathews</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-254</link>
		<dc:creator>Shawn Mathews</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-254</guid>
		<description>For everybody out there using single table inheritence, add a method like the following to the controller to fix the problem with the default sort.

def default_{pluralname of scaffold goes here}_sort
     &quot;{realtable_name}.id&quot;
end

so if your saffold line looks like this

ajax_scaffold :verygood_user

your override would look something like this

def default_verygood_users_sort
     &quot;users.id&quot;
end


Shawn</description>
		<content:encoded><![CDATA[<p>For everybody out there using single table inheritence, add a method like the following to the controller to fix the problem with the default sort.</p>
<p>def default_{pluralname of scaffold goes here}_sort<br />
     &quot;{realtable_name}.id&quot;<br />
end</p>
<p>so if your saffold line looks like this</p>
<p>ajax_scaffold :verygood_user</p>
<p>your override would look something like this</p>
<p>def default_verygood_users_sort<br />
     &quot;users.id&quot;<br />
end</p>
<p>Shawn</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ariel</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-255</link>
		<dc:creator>Ariel</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-255</guid>
		<description>Thanks for a great plugin!

When trying to have :eval =&gt; &quot;link_to(&#039;ddd&#039;, &#039;http://xxx&#039;) , I get only the html itself as TEXT in the table (i.e. &lt;a href...&gt;), while it should have been displayed as a clickable hyperlink.
Can someone please advise on what am doing wrong here?
(BTW, I&#039;m using the plugin version)
10x,
Ariel</description>
		<content:encoded><![CDATA[<p>Thanks for a great plugin!</p>
<p>When trying to have :eval =&gt; &quot;link_to(&#8216;ddd&#8217;, &#8216;http://xxx&#8217;) , I get only the html itself as TEXT in the table (i.e. &lt;a href&#8230;&gt;), while it should have been displayed as a clickable hyperlink.<br />
Can someone please advise on what am doing wrong here?<br />
(BTW, I&#8217;m using the plugin version)<br />
10x,<br />
Ariel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafamvc</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-256</link>
		<dc:creator>rafamvc</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-256</guid>
		<description>It will be very nice if we can choose to add columns, instead recreating all columns. What do you think about it Scott?</description>
		<content:encoded><![CDATA[<p>It will be very nice if we can choose to add columns, instead recreating all columns. What do you think about it Scott?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Rutherford</title>
		<link>http://blog.thatsuseful.com/2006/09/05/defining-custom-columns-with-ajax-scaffold-plugin/comment-page-1/#comment-257</link>
		<dc:creator>Scott Rutherford</dc:creator>
		<pubDate>Tue, 05 Sep 2006 13:19:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.caronsoftware.com/2007/11/25/defining-custom-columns-with-ajax-scaffold-plugin#comment-257</guid>
		<description>Hi Guys,

@Ariel - thats because the data is being sanitized. You will need to set the sanitize option on that column to false.

@rafamvc - this is upcoming in version 4.0 of the plugin....

Cheers
Scott</description>
		<content:encoded><![CDATA[<p>Hi Guys,</p>
<p>@Ariel &#8211; thats because the data is being sanitized. You will need to set the sanitize option on that column to false.</p>
<p>@rafamvc &#8211; this is upcoming in version 4.0 of the plugin&#8230;.</p>
<p>Cheers<br />
Scott</p>
]]></content:encoded>
	</item>
</channel>
</rss>
