<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.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>rails:freeze:gems &#124; freezzo.com</title>
	<link>http://www.freezzo.com</link>
	<description>A blog about web development, especially ruby on rails.</description>
	<pubDate>Thu, 04 Sep 2008 17:37:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Instant Rails Scaling through Asynchronous(Non-blocking) ActiveRecord</title>
		<link>http://www.freezzo.com/2008/09/04/instant-rails-scaling-through-asynchronousnon-blocking-activerecord/</link>
		<comments>http://www.freezzo.com/2008/09/04/instant-rails-scaling-through-asynchronousnon-blocking-activerecord/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 17:37:52 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[activerecord]]></category>

		<category><![CDATA[asynchronous]]></category>

		<category><![CDATA[non blocking]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/09/04/instant-rails-scaling-through-asynchronousnon-blocking-activerecord/</guid>
		<description><![CDATA[The guys over at NeverBlock have released a database adapter for Rails application that will severely increase the performance of ActiveRecord. Its also really easy to integrate into your application. Heres how:
Add a line to environment.rb for mongrel or thin servers:

require 'never_block/servers/thin'

 or

require 'never_block/servers/mongrel'

Change the adapter in database.yml:

adapter: neverblock_postgresql

 or

adapter: neverblock_mysql

You can also specify the [...]]]></description>
			<content:encoded><![CDATA[<p>The guys over at <a href="http://www.espace.com.eg/neverblock">NeverBlock</a> have released a database adapter for Rails application that will severely increase the performance of ActiveRecord. Its also really easy to integrate into your application. Heres how:</p>
<p>Add a line to environment.rb for mongrel or thin servers:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'never_block/servers/thin'</span></pre></div></div>

<p> or</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'never_block/servers/mongrel'</span></pre></div></div>

<p>Change the adapter in database.yml:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">adapter: neverblock_postgresql</pre></div></div>

<p> or</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">adapter: neverblock_mysql</pre></div></div>

<p>You can also specify the number of connections (default of 4):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">connections: <span style="color:#006666;">12</span></pre></div></div>

<p>More information, along with benchmarks, can be <a href="http://www.espace.com.eg/neverblock/blog/2008/09/04/neverblock-instant-scaling-for-your-rails-apps/">found here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/09/04/instant-rails-scaling-through-asynchronousnon-blocking-activerecord/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ActiveRecord conditions with association from hash</title>
		<link>http://www.freezzo.com/2008/08/29/activerecord-conditions-with-association-from-hash/</link>
		<comments>http://www.freezzo.com/2008/08/29/activerecord-conditions-with-association-from-hash/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 19:57:26 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[activerecord]]></category>

		<category><![CDATA[association]]></category>

		<category><![CDATA[conditions]]></category>

		<category><![CDATA[hash]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/08/29/activerecord-conditions-with-association-from-hash/</guid>
		<description><![CDATA[I&#8217;m sure you all know how to use the :conditions attribute when using ActiveRecord:

User.find&#40;:all, :conditions=&#62;&#91;'active = ?', true&#93;&#41;

And you may even use associations this way:

User.find&#40;:all, :include=&#62;&#91;:photos&#93;, :conditions=&#62;&#91;'photos.removed = ? and users.active = ?', false, true&#93;&#41;

But did you know that you can do this easier through hashes?

User.find&#40;:all, :conditions=&#62;&#123;:active=&#62;true&#125;&#41;
User.find&#40;:all, :include=&#62;&#91;:photos&#93;, :conditions=&#62;&#123;'photos.removed'=&#62;false, 'users.active'=&#62;true&#125;&#41;

Nothing special there, but I thought [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure you all know how to use the :conditions attribute when using ActiveRecord:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'active = ?'</span>, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>And you may even use associations this way:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:include</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:photos</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'photos.removed = ? and users.active = ?'</span>, <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>But did you know that you can do this easier through hashes?</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:active<span style="color:#006600; font-weight:bold;">=&gt;</span>true<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:include</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:photos</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'photos.removed'</span><span style="color:#006600; font-weight:bold;">=&gt;</span>false, <span style="color:#996600;">'users.active'</span><span style="color:#006600; font-weight:bold;">=&gt;</span>true<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Nothing special there, but I thought it was pretty cool. One thing you have to remember when using associations, is to include that model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/08/29/activerecord-conditions-with-association-from-hash/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Custom Rails Environments</title>
		<link>http://www.freezzo.com/2008/08/26/custom-rails-environments/</link>
		<comments>http://www.freezzo.com/2008/08/26/custom-rails-environments/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 20:24:15 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[custom]]></category>

		<category><![CDATA[environment]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/08/26/custom-rails-environments/</guid>
		<description><![CDATA[Sometimes you need to create another environment for your rails application aside from development, test, production. In this example we will create a &#8220;stage&#8221; environment. Here is how you do it.
First create the entry in your config/database.yml file:

# Stage database configuration
stage:
  adapter: sqlite3
  database: db/stage.sqlite3
  timeout: 5000

Next create a file called stage.rb [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to create another environment for your rails application aside from development, test, production. In this example we will create a &#8220;stage&#8221; environment. Here is how you do it.</p>
<p>First create the entry in your config/database.yml file:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;"># Stage database configuration</span>
stage:
  adapter: sqlite3
  database: db<span style="color:#006600; font-weight:bold;">/</span>stage.<span style="color:#9900CC;">sqlite3</span>
  timeout: <span style="color:#006666;">5000</span></pre></div></div>

<p>Next create a file called stage.rb and place it into config/environments. I usually just copy my development.rb file and then change the values as needed:</p>
<p>Finally, In your config/environment.rb file, change the ENV[&#8217;RAILS_ENV&#8217;] to:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'RAILS_ENV'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#996600;">'stage'</span></pre></div></div>

<p>Now when you boot up your server or console, just specify the &#8220;stage&#8221; environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/08/26/custom-rails-environments/feed/</wfw:commentRss>
		</item>
		<item>
		<title>session[:current_user] = @user =&gt; BAD!</title>
		<link>http://www.freezzo.com/2008/08/22/session-current-user-object-bad/</link>
		<comments>http://www.freezzo.com/2008/08/22/session-current-user-object-bad/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 17:05:37 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[login]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[session]]></category>

		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/08/22/sessioncurrent_user-user-bad/</guid>
		<description><![CDATA[I&#8217;m sure most of you already would know this, or use restful authentication that handles it for you. However, if you have some custom setup where you are loading a user object, and then storing it in session, slap to you!
Basically what I am talking about is doing this in your login method:

session&#91;:current_user&#93; = @user

Instead [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure most of you already would know this, or use restful authentication that handles it for you. However, if you have some custom setup where you are loading a user object, and then storing it in session, slap to you!</p>
<p>Basically what I am talking about is doing this in your login method:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:current_user</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@user</span></pre></div></div>

<p>Instead you should do:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:current_user</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">id</span></pre></div></div>

<p>And then in your application controller, setup a before filter like so:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> set_current_user
  <span style="color:#0066ff; font-weight:bold;">@current_user</span> = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:current_user</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>One main reason not to do that would be if you had to update some user information. If you had it stored in session, then the user would have to log out and log back in for the changes to take effect. This is of course a basic rough draft, but you get the idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/08/22/session-current-user-object-bad/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails Security - SQL Injection - Sanitize User Input!</title>
		<link>http://www.freezzo.com/2008/08/21/rails-security-sql-injection-sanitize-user-input/</link>
		<comments>http://www.freezzo.com/2008/08/21/rails-security-sql-injection-sanitize-user-input/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 14:37:02 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[hack]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[sanitize]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/08/21/rails-security-sql-injection-sanitize-user-input/</guid>
		<description><![CDATA[Even though rails makes every effort to help with security in your apps, you should still be proactive about it. Don&#8217;t just assume that your data will be safe no matter how you code. Here is a prime example.
You have a login form and you process the request like this:

user = User.find&#40;:first, :conditions=&#62;&#91;&#34;login = '#{params[:login]}'&#34;&#93;&#41;

You [...]]]></description>
			<content:encoded><![CDATA[<p>Even though rails makes every effort to help with security in your apps, you should still be proactive about it. Don&#8217;t just assume that your data will be safe no matter how you code. Here is a prime example.</p>
<p>You have a login form and you process the request like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">user = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:first</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;login = '#{params[:login]}'&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>You just essentially told  every hacker to kill your data by doing something like &#8220;&#8216;; delete from users;&#8211;&#8221;, or even worse a database drop. The appropriate way would be like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">user = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:first</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'login = ?'</span>, params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:login</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Other  things you want to make sure you do is to sanitize your views as well:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#006600; font-weight:bold;">&lt;%</span>= h <span style="color:#0066ff; font-weight:bold;">@model</span>.<span style="color:#9900CC;">value</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Assume the worse and check all your user input to make sure they can&#8217;t do anything you don&#8217;t want them to and you will have a happy APP!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/08/21/rails-security-sql-injection-sanitize-user-input/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Capistrano, CVS, and connection refused issue</title>
		<link>http://www.freezzo.com/2008/08/19/capistrano-cvs-and-connection-refused-issue/</link>
		<comments>http://www.freezzo.com/2008/08/19/capistrano-cvs-and-connection-refused-issue/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 13:04:18 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[capistrano]]></category>

		<category><![CDATA[connection refused]]></category>

		<category><![CDATA[cvs]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/08/19/capistrano-cvs-and-connection-refused-issue/</guid>
		<description><![CDATA[If you ever find yourself using CVS as your repository, and are trying to deploy your projects via capistrano, you may run into a connection refused issue.
The easiest way I found a solution around this was to modify the capistrano file: &#8220;/capistrano-2.1.0/lib/capistrano/recipes/deploy/scm/cvs.rb&#8221;. This of course is in your ruby gems folder.I could have added just [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever find yourself using CVS as your repository, and are trying to deploy your projects via capistrano, you may run into a connection refused issue.</p>
<p>The easiest way I found a solution around this was to modify the capistrano file: &#8220;/capistrano-2.1.0/lib/capistrano/recipes/deploy/scm/cvs.rb&#8221;. This of course is in your ruby gems folder.I could have added just the change to my project, but I am lazy, and need this for multiple CVS project deploying from this machine.</p>
<p>The change I made was on line 145, which I added the CVS_RSH=ssh line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#996600;">&quot;export CVS_RSH=ssh &amp;&amp; mkdir -p #{ dest } &amp;&amp; cd #{ dest }&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/08/19/capistrano-cvs-and-connection-refused-issue/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple &#038; Clean Rails Date/Time Format</title>
		<link>http://www.freezzo.com/2008/07/21/simple-clean-rails-datetime-format/</link>
		<comments>http://www.freezzo.com/2008/07/21/simple-clean-rails-datetime-format/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 20:24:35 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[date]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[strftime]]></category>

		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/07/21/simple-clean-rails-datetime-format/</guid>
		<description><![CDATA[Here is a quick, clean and easy way to get use from strftime on your date/time fields. Create a file called date_format.rb in the config/initializers directory and add the following code:

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS&#124;>.merge!&#40;
   :datetime_military =&#62; '%Y-%m-%d %H:%M',
   :datetime          =&#62; '%Y-%m-%d %I:%M%P',
   :time [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick, clean and easy way to get use from strftime on your date/time fields. Create a file called date_format.rb in the config/initializers directory and add the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#6666ff; font-weight:bold;">ActiveSupport::CoreExtensions::<span style="color:#CC00FF; font-weight:bold;">Time</span>::Conversions::DATE_FORMATS<span style="color:#006600; font-weight:bold;">|</span>>.<span style="color:#9900CC;">merge</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>
   <span style="color:#ff3333; font-weight:bold;">:datetime_military</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'%Y-%m-%d %H:%M'</span>,
   <span style="color:#ff3333; font-weight:bold;">:datetime</span>          <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'%Y-%m-%d %I:%M%P'</span>,
   <span style="color:#ff3333; font-weight:bold;">:time</span>              <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'%I:%M%P'</span>,
   <span style="color:#ff3333; font-weight:bold;">:time_military</span>     <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'%H:%M%P'</span>,
   <span style="color:#ff3333; font-weight:bold;">:datetime_short</span>    <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'%m/%d %I:%M'</span>
<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Then in your views, you can do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#0066ff; font-weight:bold;">@object</span>.<span style="color:#9900CC;">time_field</span>.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:datetime</span><span style="color:#006600; font-weight:bold;">&#41;</span>     <span style="color:#008000; font-style:italic;"># Or any other format you created</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/07/21/simple-clean-rails-datetime-format/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails TypeError (can&#8217;t dump File)</title>
		<link>http://www.freezzo.com/2008/06/18/rails-typeerror-cant-dump-file/</link>
		<comments>http://www.freezzo.com/2008/06/18/rails-typeerror-cant-dump-file/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 19:12:08 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[active_record_store]]></category>

		<category><![CDATA[attachment_fu]]></category>

		<category><![CDATA[cant dump file]]></category>

		<category><![CDATA[file_column]]></category>

		<category><![CDATA[paperclip]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[typeerror]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/06/18/rails-typeerror-cant-dump-file/</guid>
		<description><![CDATA[For a while, I kept getting exceptions from my app in the form of &#8220;TypeError (can&#8217;t dump File):&#8221;. I finally found out that this was caused when I was using active_record_store with something like file_column, attachment_fu, or paperclip. Basically whenever you&#8217;re storing a file in session, that was too large for the session, you would [...]]]></description>
			<content:encoded><![CDATA[<p>For a while, I kept getting exceptions from my app in the form of &#8220;<font class="fixed_width" face="Courier, Monospaced">TypeError (can&#8217;t dump File):&#8221;. I finally found out that this was caused when I was using active_record_store with something like file_column, attachment_fu, or paperclip. Basically whenever you&#8217;re storing a file in session, that was too large for the session, you would experience this issue. Here is how to get around it:</font></p>
<p>Say you have a model like so (This is using file_column):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Model <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  file_column <span style="color:#ff3333; font-weight:bold;">:filename</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Then in your controller you would want to add a line before you redirect off to clear that session:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Controller <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    <span style="color:#0066ff; font-weight:bold;">@model</span> = Model.<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><span style="color:#ff3333; font-weight:bold;">:model</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#0066ff; font-weight:bold;">@model</span>.<span style="color:#9900CC;">save</span>!
    params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:model</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:filename</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#0000FF; font-weight:bold;">nil</span>   <span style="color:#008000; font-style:italic;"># Reset value here</span>
    redirect_to models_path<span style="color:#006600; font-weight:bold;">&#40;</span>@model<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>As you can see, I am resetting the filename value on the model. Now it shouldn&#8217;t complain that it can&#8217;t dump the file. Happy RAILSING!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/06/18/rails-typeerror-cant-dump-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How are website with Ruby on Rails built?</title>
		<link>http://www.freezzo.com/2008/05/31/how-are-website-with-ruby-on-rails-built/</link>
		<comments>http://www.freezzo.com/2008/05/31/how-are-website-with-ruby-on-rails-built/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Q&amp;A]]></category>

		<category><![CDATA[Directory Structure]]></category>

		<category><![CDATA[Good Understanding]]></category>

		<category><![CDATA[Patrick Lenz]]></category>

		<category><![CDATA[Rhtml]]></category>

		<category><![CDATA[Ror]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[Ruby Scripts]]></category>

		<category><![CDATA[Static Html]]></category>

		<category><![CDATA[Web Applications]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/05/31/how-are-website-with-ruby-on-rails-built/</guid>
		<description><![CDATA[
RobbDogg asked: 
I&#8217;ve gone throu the Sitepoint book &#8220;Build Your Own Ruby on Rails Web Applications&#8221; by Patrick Lenz, and have a good understanding of how web applications are built, but I don&#8217;t understand how an entire website is built using RoR. Is every page gernerated by one or more Ruby scripts or are their [...]]]></description>
			<content:encoded><![CDATA[<p style="padding: 12px; float: left"><a href="/wp-content/uploads/cc/ruby_on_rails8.jpg"><img src="/wp-content/uploads/cc/ruby_on_rails8.jpg" title="ruby on rails" alt="ruby on rails" /></a></p>
<p><em><strong>RobbDogg</strong> asked: </em></p>
<p>I&#8217;ve gone throu the Sitepoint book &#8220;Build Your Own Ruby on Rails Web Applications&#8221; by Patrick Lenz, and have a good understanding of how web applications are built, but I don&#8217;t understand how an entire website is built using RoR. Is every page gernerated by one or more Ruby scripts or are their static HTML or RHTML pages that use a small amount of Ruby code to pull content from a database? I&#8217;m working on a site that uses PHP, but would like to convert it to RoR. Most of the pages use PHP to generate some content from infomation fetched from a database, and are fairly static except for the small part of the page that gets it content form the database. Would you use Ruby the same way you use PHP?  Where would I put my website page files in the Ruby directory structure? under rails_root/public ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/05/31/how-are-website-with-ruby-on-rails-built/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn Ruby on Rails or Python?</title>
		<link>http://www.freezzo.com/2008/05/29/learn-ruby-on-rails-or-python/</link>
		<comments>http://www.freezzo.com/2008/05/29/learn-ruby-on-rails-or-python/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
		
		<category><![CDATA[Q&amp;A]]></category>

		<category><![CDATA[Calculator]]></category>

		<category><![CDATA[Direction]]></category>

		<category><![CDATA[Learn A Language]]></category>

		<category><![CDATA[Learn Php]]></category>

		<category><![CDATA[Lot]]></category>

		<category><![CDATA[Perl]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[Web Host]]></category>

		<guid isPermaLink="false">http://www.freezzo.com/2008/05/29/learn-ruby-on-rails-or-python/</guid>
		<description><![CDATA[
someoneoutthereishere asked: 
I have some experience with C, and am looking to learn a language that can do some web based stuff. I&#8217;ve done a bit of Perl, but don&#8217;t really want to learn it. PHP is there also, but again, seems like it may be a bit outdated(?)I&#8217;ve heard a lot about Ruby on [...]]]></description>
			<content:encoded><![CDATA[<p style="padding: 12px; float: left"><a href="/wp-content/uploads/cc/ruby_on_rails12.jpg"><img src="/wp-content/uploads/cc/ruby_on_rails12.jpg" title="ruby on rails" alt="ruby on rails" /></a></p>
<p><em><strong>someoneoutthereishere</strong> asked: </em></p>
<p>I have some experience with C, and am looking to learn a language that can do some web based stuff. I&#8217;ve done a bit of Perl, but don&#8217;t really want to learn it. PHP is there also, but again, seems like it may be a bit outdated(?)I&#8217;ve heard a lot about Ruby on Rails, but from the description on their website it seems to mainly be used for database driven sites.</p>
<p>Python is also popular and seems to be learnable (for my level  of experience).</p>
<p>My web host supports both, so I&#8217;m mostly just looking for a direction on which would be more useful to learn. The projects I would like to use it for would not be strictly database driven things (which as mentioned seem to be Ruby&#8217;s specialty), just general web things like um for example a simple calculator or form processor or things like that. Any suggestions, and if so, why? Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freezzo.com/2008/05/29/learn-ruby-on-rails-or-python/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
