<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.2" -->
<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/"
	>

<channel>
	<title>McGinTech</title>
	<link>http://www.mcgintech.com</link>
	<description>(because Initech was taken LOL)</description>
	<pubDate>Fri, 30 Mar 2007 14:14:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>
	<language>en</language>
			<item>
		<title>ruby: no such file to load &#8212; *gem name* (LoadError)</title>
		<link>http://www.mcgintech.com/2007/03/30/ruby-on-rails/ruby-no-such-file-to-load-gem-name-loaderror/</link>
		<comments>http://www.mcgintech.com/2007/03/30/ruby-on-rails/ruby-no-such-file-to-load-gem-name-loaderror/#comments</comments>
		<pubDate>Fri, 30 Mar 2007 14:11:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.mcgintech.com/2007/03/30/uncategorized/ruby-no-such-file-to-load-gem-name-loaderror/</guid>
		<description><![CDATA[If you are trying to run a script that uses a gem library and you are getting a &#8220;LoadError&#8221; like this&#8230; 

ruby: no such file to load &#8212; rubyzip &#40;LoadError&#41;
&#160;
&#8230;make sure that you have &#8220;required&#8221; rubygems and also the gem itself, like this:

require &#8216;rubygems&#8217;
require &#8216;zip/zipfilesystem&#8217;
&#160;
]]></description>
			<content:encoded><![CDATA[<p>If you are trying to run a script that uses a gem library and you are getting a &#8220;LoadError&#8221; like this&#8230; </p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
ruby: no such file to load &#8212; rubyzip <span style="color: #66cc66;">&#40;</span>LoadError<span style="color: #66cc66;">&#41;</span><br />
&nbsp;</div>
<p>&#8230;make sure that you have &#8220;required&#8221; rubygems and also the gem itself, like this:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
<span style="color:#CC0066; font-weight:bold;">require</span> &#8216;rubygems&#8217;<br />
<span style="color:#CC0066; font-weight:bold;">require</span> &#8216;zip/zipfilesystem&#8217;<br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mcgintech.com/2007/03/30/ruby-on-rails/ruby-no-such-file-to-load-gem-name-loaderror/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Modifying Plugins - A warning.</title>
		<link>http://www.mcgintech.com/2007/03/21/ruby-on-rails/modifying-plugins-a-warning/</link>
		<comments>http://www.mcgintech.com/2007/03/21/ruby-on-rails/modifying-plugins-a-warning/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 14:00:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.mcgintech.com/2007/03/21/ruby-on-rails/modifying-plugins-a-warning/</guid>
		<description><![CDATA[I&#8217;m just throwing this out there to all rails newbies and anybody who might have forgotten how things work.  In either case, I&#8217;m sure you might be banging  your head against the wall wondering why your modifications to a ruby on rails plugin is not working and most likely doing nothing at all.
If [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just throwing this out there to all rails newbies and anybody who might have forgotten how things work.  In either case, I&#8217;m sure you might be banging  your head against the wall wondering why your modifications to a ruby on rails plugin is not working and most likely doing nothing at all.</p>
<p>If that is the case, it is probably because <strong>you MUST restart WEBrick after each change!</strong></p>
<p>The plugins are loaded initially and the code is stored and not accessed again until the server is restarted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcgintech.com/2007/03/21/ruby-on-rails/modifying-plugins-a-warning/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A single form for acts_as_attachment</title>
		<link>http://www.mcgintech.com/2007/03/20/ruby-on-rails/a-single-form-for-acts_as_attachment/</link>
		<comments>http://www.mcgintech.com/2007/03/20/ruby-on-rails/a-single-form-for-acts_as_attachment/#comments</comments>
		<pubDate>Tue, 20 Mar 2007 12:50:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[When I first downloaded the Ruby on Rails plugin acts_as_attachment, I couldn&#8217;t understand why the only tutorials I could find did not show how to update the model and the attachment model in the same form.  After all, why would you want to put your user through two actions when one would suffice?
I will [...]]]></description>
			<content:encoded><![CDATA[<p>When I first downloaded the Ruby on Rails plugin acts_as_attachment, I couldn&#8217;t understand why the only tutorials I could find did not show how to update the model and the attachment model in the same form.  After all, why would you want to put your user through two actions when one would suffice?</p>
<p>I will expand on <a href="http://technoweenie.stikipad.com/plugins/show/Acts+as+Attachment" title="the DVD Cover example" target="_blank">the DVD Cover example</a>.  Some of the code below is blatantly stolen from that tutorial. <img src='http://www.mcgintech.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Intall the plugin:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
<p>&gt; script/plugin <span style="color: #000066;">source</span> http://svn.techno-weenie.net/projects/plugins<br />
&gt; script/plugin install acts_as_attachment<br />
&gt; rake test_plugins <span style="color: #0000ff;">PLUGIN=</span>acts_as_attachment</div>
<p>Generate the Models:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
<p>&gt; script/generate model dvd<br />
&gt; script/generate attachment_model dvd_cover</div>
<p>Update your Database:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:400px;">
&nbsp; &nbsp;create_table :dvd <span style="color:#9966CC; font-weight:bold;">do</span> |t|<br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;name&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;studio&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;producer&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></p>
<p>&nbsp; &nbsp;create_table :dvd_covers <span style="color:#9966CC; font-weight:bold;">do</span> |t|<br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;dvd_id&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;content_type&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;filename&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;size&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span></p>
<p>&nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># The following fields are not mandatory.</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;parent_id&quot;</span>,&nbsp; :<span style="color:#CC0066; font-weight:bold;">integer</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;thumbnail&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">string</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;width&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> <span style="color:#996600;">&quot;height&quot;</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
<p>Edit the Models:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
<p><span style="color:#9966CC; font-weight:bold;">class</span> Dvd &lt; ActiveRecord::Base<br />
&nbsp; has_one :dvd_cover<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">
<p><span style="color:#9966CC; font-weight:bold;">class</span> DvdCover &lt; ActiveRecord::Base<br />
&nbsp; belongs_to :dvd<br />
&nbsp; acts_as_attachment :storage =&gt; :file_system<br />
&nbsp; validates_as_attachment<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div>
<p>The Controller:</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:400px;">
<p><span style="color:#9966CC; font-weight:bold;">class</span> DvdController &lt; ApplicationController</p>
<p>&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> index<br />
&nbsp; &nbsp; @dvd = Dvd.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>:all<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></p>
<p>&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> new_dvd<br />
&nbsp; &nbsp; @dvd = params<span style="color:#006600; font-weight:bold;">&#91;</span>:id<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>? ? Dvd.<span style="color:#9900CC;">new</span> : Dvd.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span>:id<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; @dvd_cover = DvdCover.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span>:dvd_cover<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></p>
<p>&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> request.<span style="color:#9900CC;">post</span>?<br />
&nbsp; &nbsp; &nbsp; @dvd.<span style="color:#9900CC;">attributes</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span>:dvd<span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; @dvd_cover.<span style="color:#9900CC;">attributes</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span>:dvd_cover<span style="color:#006600; font-weight:bold;">&#93;</span></p>
<p>&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> save_dvd<br />
&nbsp; &nbsp; &nbsp; &nbsp; Dvd.<span style="color:#9900CC;">transaction</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @dvd.<span style="color:#9900CC;">save</span>!<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @dvd_cover.<span style="color:#9900CC;">dvd_id</span> = @dvd.<span style="color:#9900CC;">id</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @dvd_cover.<span style="color:#9900CC;">save</span>!<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></p>
<p>&nbsp; &nbsp; &nbsp; redirect_to<span style="color:#006600; font-weight:bold;">&#40;</span>:action =&gt; <span style="color:#996600;">&quot;index&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> save_dvd<br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">rescue</span> ActiveRecord::RecordInvalid<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></p>
<p><span style="color:#9966CC; font-weight:bold;">end</span></div>
<p>The View:<br />
(app/views/new_dvd.rhtml)</p>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:400px;">
<p>&lt;%= error_messages_for :dvd %&gt;<br />
&lt;%= error_messages_for :dvd_cover %&gt;</p>
<p>&lt;%= form_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:action =&gt; <span style="color:#996600;">&quot;new_dvd&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#006600; font-weight:bold;">&#123;</span> :multipart=&gt;true <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;</p>
<p>&lt;label <span style="color:#9966CC; font-weight:bold;">for</span>=<span style="color:#996600;">&quot;name&quot;</span>&gt;&lt;strong&gt;Name:&lt;/strong&gt;&lt;/label&gt;</p>
<p>&lt;%= text_field<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;dvd&quot;</span>, <span style="color:#996600;">&quot;name&quot;</span>, <span style="color:#996600;">&quot;size&quot;</span> =&gt; <span style="color:#006666;">50</span>, <span style="color:#996600;">&quot;maxlength&quot;</span> =&gt; <span style="color:#006666;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;</p>
<p>&lt;label <span style="color:#9966CC; font-weight:bold;">for</span>=<span style="color:#996600;">&quot;name&quot;</span>&gt;&lt;strong&gt;Studio:&lt;/strong&gt;&lt;/label&gt;</p>
<p>&lt;%= text_field<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;dvd&quot;</span>, <span style="color:#996600;">&quot;studio&quot;</span>, <span style="color:#996600;">&quot;size&quot;</span> =&gt; <span style="color:#006666;">50</span>, <span style="color:#996600;">&quot;maxlength&quot;</span> =&gt; <span style="color:#006666;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;</p>
<p>&lt;label <span style="color:#9966CC; font-weight:bold;">for</span>=<span style="color:#996600;">&quot;name&quot;</span>&gt;&lt;strong&gt;Producer:&lt;/strong&gt;&lt;/label&gt;</p>
<p>&lt;%= text_field<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;dvd&quot;</span>, <span style="color:#996600;">&quot;producer&quot;</span>, <span style="color:#996600;">&quot;size&quot;</span> =&gt; <span style="color:#006666;">50</span>, <span style="color:#996600;">&quot;maxlength&quot;</span> =&gt; <span style="color:#006666;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;</p>
<p>&lt;label <span style="color:#9966CC; font-weight:bold;">for</span>=<span style="color:#996600;">&quot;name&quot;</span>&gt;&lt;strong&gt;DVD Cover:&lt;/strong&gt;&lt;/label&gt;</p>
<p>&lt;%= file_field<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;dvd_cover&quot;</span>, <span style="color:#996600;">&quot;uploaded_data&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;</p>
<p>&lt;%= submit_tag &#8216;Create DVD&#8217; %&gt;</p>
<p>&lt;%= end_form_tag %&gt;</p></div>
<div class="ch_code_container" style="font-family: monospace;white-space: nowrap;height:100%;">&nbsp;</div>
<p>This will give you 1 form to create the DVD and upload the DVD Cover.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcgintech.com/2007/03/20/ruby-on-rails/a-single-form-for-acts_as_attachment/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
