<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Chris Oliver / @excid3</title>
	
	<link>http://excid3.com/blog</link>
	<description>A few fries short of a happy meal</description>
	<lastBuildDate>Fri, 18 May 2012 00:08:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/excid3" /><feedburner:info uri="excid3" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>excid3</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Setting Up Ubuntu 12.04 with Ruby 1.9.3, Rails, Nginx, Passenger, and PostgreSQL or MySQL</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/makIdq5UoTE/</link>
		<comments>http://excid3.com/blog/setting-up-ubuntu-12-04-with-ruby-1-9-3-nginx-passenger-and-postgresql-or-mysql/#comments</comments>
		<pubDate>Mon, 07 May 2012 16:00:13 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1561</guid>
		<description><![CDATA[With the recent release of Ubuntu 12.04, we&#8217;ve got an even easier way to setup our webserver. Let me walk you through the steps: Create Our Deploy User One of the first things we want to make sure we get done is that we have a deploy user. This going to be the user that [...]]]></description>
			<content:encoded><![CDATA[<p>With the recent release of Ubuntu 12.04, we&#8217;ve got an even easier way to setup our webserver. Let me walk you through the steps:</p>
<h2>Create Our Deploy User</h2>
<p>One of the first things we want to make sure we get done is that we have a deploy user. This going to be the user that deploys the website and the same user that the website is run as.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> adduser deploy</pre></div></div>

<h2>Update and install our dependencies</h2>
<p>This downloads the latest list of available software versions. We&#8217;ll install our build dependencies for later.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-y</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core</pre></div></div>

<h2>Install Ruby 1.9.3</h2>
<p>We&#8217;re going to install Ruby 1.9.3 from source. Note that -p194 may not be the latest version of Ruby. Check out ruby-lang.org to get the latest version and replace it in the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>ftp.ruby-lang.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.9</span><span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.3-p194.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> ruby-1.9.3-p194.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> ruby-1.9.3-p194<span style="color: #000000; font-weight: bold;">/</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;gem: --no-ri --no-rdoc&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.gemrc
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> bundler</pre></div></div>

<h2>Install Nginx with Passenger</h2>
<p>Since we&#8217;ll be using Nginx for serving our application, we&#8217;re going to install it using the latest package from a user repository:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger
<span style="color: #c20cb9; font-weight: bold;">sudo</span> passenger-install-nginx-module
<span style="color: #666666; font-style: italic;"># Choose &quot;download, compile, and install Nginx for me&quot;</span>
<span style="color: #666666; font-style: italic;"># Accept defaults for any other questions it asks you</span></pre></div></div>

<p>Next we want to setup a script to allow us to control Nginx. We&#8217;re going to grab this from Linode:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> init-deb.sh http:<span style="color: #000000; font-weight: bold;">//</span>library.linode.com<span style="color: #000000; font-weight: bold;">/</span>assets<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">660</span>-init-deb.sh
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> init-deb.sh <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>update-rc.d <span style="color: #660033;">-f</span> nginx defaults</pre></div></div>

<p>You can now control Nginx with this script. To start and stop the server manually, you run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx stop
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx start</pre></div></div>

<p>We can verify nginx is running by opening up Firefox and going to <a href="http://localhost">http://localhost</a></p>
<p><a href="http://cl.ly/100L0R3Z1j252V072z1F/Screen%20Shot%202012-05-05%20at%202.46.07%20PM.png"><img alt="" src="http://cl.ly/100L0R3Z1j252V072z1F/Screen%20Shot%202012-05-05%20at%202.46.07%20PM.png" title="Nginx" class="alignnone" width="600" height="450" /></a></p>
<p>After installation, you&#8217;ll get some tips on how to configure an Nginx server to listen on a domain and enable passenger for it. You&#8217;ll want to save this for later when you setup your deployment scripts. The root path there will be the public directory where you setup your Rails app folder.</p>
<p>One of the first things you want to do is edit the <code>nginx.conf</code> so that you can tell it to run as the deploy user. This file will be <code>/opt/nginx/conf/nginx.conf</code> and you can add this as the first line:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">user deploy staff<span style="color: #339933;">;</span></pre></div></div>

<h4>Alternative: Nginx With Unicorn</h4>
<p>An alternative to Passenger is to install Nginx from it&#8217;s PPA and use Unicorn instead. This is preferred, but it takes a bit more setup. I won&#8217;t get too much into this, but you can install just plain Nginx with the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> add-apt-repository ppa:nginx<span style="color: #000000; font-weight: bold;">/</span>stable
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nginx
<span style="color: #c20cb9; font-weight: bold;">sudo</span> service nginx start</pre></div></div>

<p>After this, I recommend checking out <a href="http://railscasts.com/episodes/335-deploying-to-a-vps">Deploying To A VPS</a> by Ryan Bates for setting up Unicorn.</p>
<h2>Setup your database</h2>
<p>Our next step is installing our database server. I&#8217;d recommend using PostgreSQL but many of you may prefer MySQL. Take your pick:</p>
<h4>MySQL</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server mysql-client libmysqlclient-dev</pre></div></div>

<p>OR </p>
<h4>PostgreSQL 9.1.3</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> postgresql libpq-dev</pre></div></div>

<h2>Node.js for the Rails asset pipeline</h2>
<p>One of the other things you&#8217;ll want is Node.js. This will help us do the compiling of assets on deployments. It&#8217;s a pretty quick installation to get the latest version:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">sudo apt<span style="color:#006600; font-weight:bold;">-</span>add<span style="color:#006600; font-weight:bold;">-</span>repository ppa:chris<span style="color:#006600; font-weight:bold;">-</span>lea<span style="color:#006600; font-weight:bold;">/</span>node.<span style="color:#9900CC;">js</span>
sudo apt<span style="color:#006600; font-weight:bold;">-</span>get <span style="color:#006600; font-weight:bold;">-</span>y update
sudo apt<span style="color:#006600; font-weight:bold;">-</span>get <span style="color:#006600; font-weight:bold;">-</span>y install nodejs</pre></div></div>

<h2>Configure Your Rails App</h2>
<p>You&#8217;ll need to get a copy of your rails application on the webserver. The best place to do this is to store it in the home directory of the deploy user. I recommend using Capistrano to set this up. Afterwards, you can modify your <code>/opt/nginx/conf/nginx.conf</code> file to contain a new passenger server like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">server <span style="color: #009900;">&#123;</span>
	listen <span style="color: #CC0000;">80</span><span style="color: #339933;">;</span>
	server_name example.<span style="color: #660066;">com</span><span style="color: #339933;">;</span>
	root <span style="color: #339933;">/</span><span style="color: #000066;">home</span><span style="color: #339933;">/</span>deploy<span style="color: #339933;">/</span>myapplication<span style="color: #339933;">/</span><span style="color: #003366; font-weight: bold;">public</span><span style="color: #339933;">;</span>   # <span style="color: #339933;">&lt;---</span> be sure to point to <span style="color: #3366CC;">'public'</span><span style="color: #339933;">!</span>
	passenger_enabled on<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just change the application folder name and the server name and then restart the nginx service.</p>
<h2>Conclusion</h2>
<p>And there you have it! Your server is configured and ready for deployments.</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/makIdq5UoTE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/setting-up-ubuntu-12-04-with-ruby-1-9-3-nginx-passenger-and-postgresql-or-mysql/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/setting-up-ubuntu-12-04-with-ruby-1-9-3-nginx-passenger-and-postgresql-or-mysql/</feedburner:origLink></item>
		<item>
		<title>Don’t Settle</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/-U7x2PAtP_Y/</link>
		<comments>http://excid3.com/blog/dont-settle/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 15:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1556</guid>
		<description><![CDATA[&#8220;You&#8217;ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;You&#8217;ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven&#8217;t found it yet, keep looking. Don&#8217;t settle. As with all matters of the heart, you&#8217;ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don&#8217;t settle.&#8221;</p>
<p><strong>Steve Jobs</strong>
</p></blockquote>
<img src="http://feeds.feedburner.com/~r/excid3/~4/-U7x2PAtP_Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/dont-settle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/dont-settle/</feedburner:origLink></item>
		<item>
		<title>Flip A Coin</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/5X8f-EhohuE/</link>
		<comments>http://excid3.com/blog/flip-a-coin/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 15:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1541</guid>
		<description><![CDATA[&#8220;When you have to make a hard decision, flip a coin. When that coin is in the air, you suddenly know what you&#8217;re hoping for.&#8221; This quote has hit home on several occasions. There have been a few times in life where I was pretty sure I didn&#8217;t want to continue. The problem was that [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;When you have to make a hard decision, flip a coin.<br />
When that coin is in the air, you suddenly know what you&#8217;re hoping for.&#8221;</p></blockquote>
<p>This quote has hit home on several occasions. There have been a few times in life where I was pretty sure I didn&#8217;t want to continue. The problem was that it was easier to continue than to sit down and make the realization I needed a change.</p>
<p>For most decisions, you probably lean to one side whether you want to admit it or not. Have someone else ask you the decision and flip the coin. The answer now feels out of your control. Allow yourself a second to think before they show you the result. It quickly becomes clear that you want a specific result. </p>
<h2>Decisions can be very hard. Especially when you can&#8217;t make up your mind.</h2>
<p>Robbie Abed recently <a href="http://robbieabed.com/fire-me-i-beg-you/">discussed a situation</a> he was in previously at a job he didn&#8217;t like. This same situation happened to me several months ago. I didn&#8217;t want to come into work anymore and secretly wished I had a reason to leave. About a month after realizing this, I left as well.</p>
<p>In one of his many amazing blog posts, Derek Sivers <a href="http://sivers.org/hellyeah">talks about decision making</a> by either saying HELL YEAH or no. Now this works wonderfully if you&#8217;re not making a decision about starting something new. It&#8217;s easy to dismiss this tactic when you&#8217;re miserable. When you&#8217;re doing something soul sucking, you sometimes can&#8217;t bring yourself to say &#8220;hell yeah!&#8221; anymore. Flipping a coin can help you realize what you want to say &#8220;hell yeah!&#8221; to.</p>
<h2>The truth is you&#8217;re always better off</h2>
<p>When it comes to making a decision about pursuing a new path or staying, it&#8217;s always best to go with your gut feeling. </p>
<p>Do you immediately lean towards staying? Then you need to bring it up to your boss and coworkers about changes that need to be made. Truth is, you&#8217;re happy where you&#8217;re at, mostly. Some things aren&#8217;t working, so bring it up and get them fixed. </p>
<p>If you lean the other direction, then quit. You&#8217;ve always wanted to build things? Then go. In the world we live in today, you&#8217;ve got nothing stopping you. You can travel around the world in a matter of hours. A team of 13 <a href="http://blog.instagram.com/post/20785013897/instagram-facebook">can sell their company</a> for $1 billion after just 2 years.</p>
<p>There is NO REASON you shouldn&#8217;t be doing what makes you excited day in and day out.</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/5X8f-EhohuE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/flip-a-coin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/flip-a-coin/</feedburner:origLink></item>
		<item>
		<title>Of Course</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/9yfdYXRGLeo/</link>
		<comments>http://excid3.com/blog/of-course/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 16:00:06 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1533</guid>
		<description><![CDATA[Most companies (including web startups), he said, are looking to “wow” with their products, when in reality what they should be looking for is an “‘of course’ reaction from their users.” Puzzled, I looked at him. And then it hit me: Great design means that one look and the end user reacts by knowing what [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Most companies (including web startups), he said, are looking to “wow” with their products, when in reality what they should be looking for is an “‘of course’ reaction from their users.”</p>
<p>Puzzled, I looked at him. And then it hit me: Great design means that one look and the end user reacts by knowing what to do with a knob or a button, without as much as even thinking about it. Of course this knob is what turns the volume up, or brings up the home screen.</p>
<p>This of course factor is at the heart of every great design — from the iPhone to the Braun alarm radio. And it’s an important lesson that every startup and entrepreneur should remember. Whether your company is making a physical product or a web service or mobile application, it’s essential for you to think about design.</p>
<p><strong>Christian Lindholm</strong>
</p></blockquote>
<p>Source: <a href="http://om.co/2012/04/05/the-of-course-principle-of-design/">http://om.co/2012/04/05/the-of-course-principle-of-design/</a></p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/9yfdYXRGLeo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/of-course/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/of-course/</feedburner:origLink></item>
		<item>
		<title>Maybe You’re Just Making Excuses</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/M5Qkl14eTvU/</link>
		<comments>http://excid3.com/blog/maybe-youre-just-making-excuses/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 15:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1419</guid>
		<description><![CDATA[Successful people must have a property about them that makes them successful. The media likes to explain this as being magical. This is rarely the case. What you don&#8217;t see is the years of hard work put into learning the ropes. Rovio spent 8 years developing games before Angry Birds was a hit. Zuckerberg spent [...]]]></description>
			<content:encoded><![CDATA[<p><iframe width="640" height="360" src="http://www.youtube.com/embed/PH8nTfxwByY?feature=player_embedded" frameborder="0" allowfullscreen></iframe></p>
<p>Successful people must have a property about them that makes them successful. The media likes to explain this as being magical. This is rarely the case. What you don&#8217;t see is the years of hard work put into learning the ropes. </p>
<p>Rovio spent 8 years developing games before Angry Birds was a hit. Zuckerberg spent hours upon hours getting good at programming before he could actually build the first version of Facebook. Steve Jobs got fired from Apple before he came back and turned the company around. Failure and hard work are things they embraced.</p>
<blockquote><p>I&#8217;ve missed more than 9000 shots in my career. I&#8217;ve lost almost 300 games. 26 times, I&#8217;ve been trusted to take the game winning shot and missed. I&#8217;ve failed over and over and over again in my life. And that is why I succeed.<br />
<strong>Michael Jordan</strong></p></blockquote>
<p>Failure is just a part of life. Don&#8217;t fear it. Maybe you&#8217;re just making excuses.</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/M5Qkl14eTvU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/maybe-youre-just-making-excuses/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/maybe-youre-just-making-excuses/</feedburner:origLink></item>
		<item>
		<title>Have A Higher Purpose</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/CIBW4TcKDF8/</link>
		<comments>http://excid3.com/blog/have-a-higher-purpose/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 15:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1511</guid>
		<description><![CDATA[Watching @deadmau5 live stream has made me realize how technology frustrates all of us including rock star dudes. live.deadmau5.com &#8212; Cheston Lee (@Cheston) March 20, 2012 I came across this tweet earlier via my buddy Jacob and it got me thinking. In life, we can easily fall victim to getting caught up in the moment. [...]]]></description>
			<content:encoded><![CDATA[<blockquote class="twitter-tweet"><p>Watching @<a href="https://twitter.com/deadmau5">deadmau5</a> live stream has made me realize how technology frustrates all of us including rock star dudes. <a href="http://t.co/ErMoROiG" title="http://live.deadmau5.com/">live.deadmau5.com</a></p>
<p>&mdash; Cheston Lee (@Cheston) <a href="https://twitter.com/Cheston/status/182251275465928707" data-datetime="2012-03-20T23:44:24+00:00">March 20, 2012</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>I came across this tweet earlier via my buddy <a href="https://biosshadow.com">Jacob</a> and it got me thinking. </p>
<p>In life, we can easily fall victim to getting caught up in the moment. The specifics of your job and life can take away from your consciousness of the higher goals that you have. Do you want to change the world? Yes, we all do. But in what way?</p>
<p>For me, I want to make software simpler. One example of what I want to accomplish is the transition to a Macbook that my parents have went through in the past several months. Previously when I would visit, they would have a list of computer problems waiting for me. &#8220;The printer driver isn&#8217;t working.&#8221; &#8220;iTunes won&#8217;t sync.&#8221; &#8220;I don&#8217;t know where my files are from the camera after I transferred them via USB.&#8221; And then I gave them my Macbook. I haven&#8217;t heard a peep from them since. It was a seamless transition, and they have had absolutely zero problems and can do more now than they could before. Their lives are now simpler and much more productive.</p>
<p>To me, being able to make regular software simpler can have a profound effect. Nontechnical people will be able to accomplish more quicker using simpler software. This is what I want to do. I want to change the world by adding simplicity and minimalism to an overly complicated world.</p>
<p>Rails exemplifies this in the development of web applications. Steam does this for video games by removing the complexities around it. There are plenty of people with similar values in tons of different areas.</p>
<h2>One of the keys to success is having defined your set of values. Things you believe in.</h2>
<p>If you take a look at everyone who has been incredibly successful, they have had a specific set of goals and values. They made their decisions based upon these values, and stuck by them no matter what.</p>
<p>Every single president had strong beliefs that were unwavering. Steve Jobs had that. Every really successful company has grown out of a set of values . They weren&#8217;t without their enemies, but that comes with the territory. </p>
<p>On the other hand, if you analyze those who aren&#8217;t successful, you&#8217;ll notice that they have wavering beliefs. They are unsure of themselves which remove the ability for people to stand behind them. You can&#8217;t support someone who changes their mind month to month.</p>
<p>Which leads into my next point&#8230;</p>
<h2>Defining your values makes you a leader</h2>
<p>Sometimes people are searching for something to believe in. They&#8217;re questioning their beliefs and looking for someone to align themselves with. If you talk about your values, it is easy to attract people with similar values. The best tech companies write tons of blog posts about their values, and this grows a community of similar people. The potential employees with similar values are already exposed, so they know exactly where to go when they are looking for a job.</p>
<p>Knowing exactly what your values are puts you in a unique position. Most people don&#8217;t know what theirs are, and it is refreshing to see someone who does. TED Talks always have inspiring speakers. Everyone of them knows what they live for. We are attracted to this because it is inspirational. They are amazing individuals. We want to be like them.</p>
<p>And that&#8217;s easy. You&#8217;ve just got to become one yourself.</p>
<h2>Write down your values</h2>
<p>So what things do you believe in? What would values would you never sacrifice? This is important on both a personal and a career level.</p>
<p>Decisions are <strong>easy</strong> when you have a set of values. Does eating two cookies fit your personal value of a healthy lifestyle? Nope. Done, no arguing with yourself, no second guessing. Does arguing for 3 hours about the company color scheme help achieve your company&#8217;s goals? Nope. Look at your values. &#8220;We want to give the best customer experience we can.&#8221; Well then I guess the exact color of the website doesn&#8217;t matter when everyone could be answering customer questions and building the product features out.</p>
<h2>Conclusion</h2>
<p>It&#8217;s easy for things to be blown out of proportion. Stupid problems end up much larger than they should be. Having a set of values allows you to refocus and put them back into perspective. Oh this doesn&#8217;t really matter AND we can change it pretty much whenever? Then just pick one and we&#8217;ll fix it later if it doesn&#8217;t work out. No biggie.</p>
<p>So what are your values?</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/CIBW4TcKDF8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/have-a-higher-purpose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/have-a-higher-purpose/</feedburner:origLink></item>
		<item>
		<title>Your Taste Is What Disappoints You</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/UKwLiWfe1Z0/</link>
		<comments>http://excid3.com/blog/your-taste-is-what-disappoints-you/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 16:00:21 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1506</guid>
		<description><![CDATA[“Nobody tells this to people who are beginners, I wish someone told me. All of us who do creative work, we get into it because we have good taste. But there is this gap. For the first couple years you make stuff, it’s just not that good. It’s trying to be good, it has potential, [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>“Nobody tells this to people who are beginners, I wish someone told me. All of us who do creative work, we get into it because we have good taste. But there is this gap. For the first couple years you make stuff, it’s just not that good. It’s trying to be good, it has potential, but it’s not. But your taste, the thing that got you into the game, is still killer. And your taste is why your work disappoints you. A lot of people never get past this phase, they quit. Most people I know who do interesting, creative work went through years of this. We know our work doesn’t have this special thing that we want it to have. We all go through this. And if you are just starting out or you are still in this phase, you gotta know its normal and the most important thing you can do is do a lot of work. Put yourself on a deadline so that every week you will finish one story. It is only by going through a volume of work that you will close that gap, and your work will be as good as your ambitions. And I took longer to figure out how to do this than anyone I’ve ever met. It’s gonna take awhile. It’s normal to take awhile. You’ve just gotta fight your way through.”</p></blockquote>
<p>-Ira Glass</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/UKwLiWfe1Z0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/your-taste-is-what-disappoints-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/your-taste-is-what-disappoints-you/</feedburner:origLink></item>
		<item>
		<title>Rails Tip #8: Capistrano Colors</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/c9_LBpEf0XI/</link>
		<comments>http://excid3.com/blog/rails-tip-8-capistrano-colors/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 16:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1497</guid>
		<description><![CDATA[If you&#8217;ve used Capistrano before, you&#8217;re familiar with the large error logs. Finding errors is, well, a hassle. You&#8217;ve got a whole slew of text, some just saying what command it&#8217;s going to execute next, sometimes errors, sometimes just output from Bundler or whatever it&#8217;s running. Wouldn&#8217;t it be nice if we could colorize Capistrano? [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve used Capistrano before, you&#8217;re familiar with the large error logs. Finding errors is, well, a hassle. You&#8217;ve got a whole slew of text, some just saying what command it&#8217;s going to execute next, sometimes errors, sometimes just output from Bundler or whatever it&#8217;s running. </p>
<h2>Wouldn&#8217;t it be nice if we could colorize Capistrano?</h2>
<p>And you can! Just install the <code>capistrano_colors</code> gem on your local machine and we&#8217;ll set it up to run on every capistrano deployment without having to modify your existing deploy scripts.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">  gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano_colors</pre></div></div>

<p>And next, we add a configuration to your <code>~/.caprc</code> file:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'capistrano_colors'</span>    
&nbsp;
capistrano_color_matchers = <span style="color:#006600; font-weight:bold;">&#91;</span>
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>command finished<span style="color:#006600; font-weight:bold;">/</span>,       <span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:hide</span>,      <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>executing command<span style="color:#006600; font-weight:bold;">/</span>,      <span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:blue</span>,      <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:underscore</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>^transaction: commit$<span style="color:#006600; font-weight:bold;">/</span>,  <span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:magenta</span>,   <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:blink</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
  <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>git<span style="color:#006600; font-weight:bold;">/</span>,                    <span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:white</span>,     <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:reverse</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
<span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
colorize<span style="color:#006600; font-weight:bold;">&#40;</span> capistrano_color_matchers <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>And that&#8217;s as simple as it is! When you&#8217;re done your output should look something like this:</p>
<p><img src="http://cl.ly/3a0g0a2h2c0o2i3L3k1W/Screen%20Shot%202012-03-13%20at%2010.31.19%20PM.png" alt="capistrano colors"/></p>
<p><strong>This a must have if you&#8217;re using Capistrano for deployments.</strong> Check out the source here: <a href="https://github.com/stjernstrom/capistrano_colors">https://github.com/stjernstrom/capistrano_colors</a></p>
<p>Got any other awesome deployment tips? Share them with me in the comments!</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/c9_LBpEf0XI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/rails-tip-8-capistrano-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/rails-tip-8-capistrano-colors/</feedburner:origLink></item>
		<item>
		<title>Don’t tell me you want to change the world. Show me.</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/LjoGyrvv8Zw/</link>
		<comments>http://excid3.com/blog/dont-tell-me-you-want-to-change-the-world-show-me/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 16:00:00 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1432</guid>
		<description><![CDATA[Have you ever known someone who was a talker? They could literally sit there all day and talk about how excited they were about doing something, and yet, at the end of the day nothing had been done. We&#8217;ve all done it actually. Some of us to a further extent than others. We don&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever known someone who was a <strong>talker</strong>? They could literally sit there all day and talk about how excited they were about doing something, and yet, at the end of the day nothing had been done. We&#8217;ve all done it actually. Some of us to a further extent than others.</p>
<p>We don&#8217;t want to be naive going into a new venture. Whether it&#8217;s a startup or a relationship, we want to feel like we have a good understanding of what we&#8217;re getting into before we make our attempt. In reality, this can set you back a long time. <strong>You may never feel confident enough to get started.</strong></p>
<p>Do you know what will make you feel confident enough though? <strong>Experience.</strong></p>
<p>If you&#8217;re a programmer, you&#8217;ll know this feeling. You can see example code that works, but until you actually run it for yourself, you don&#8217;t fully realize how it works. Just the simple act of doing allows you to have a much greater understanding, no matter how true the words you read are. Just reading this blog post won&#8217;t make you realize how much doing matters. You have to do in order to truly realize this. You&#8217;re probably thinking &#8220;oh he&#8217;s right, I should work harder&#8221; but that&#8217;s as far as you take it.</p>
<p>If you want to become an entrepreneur, working at fulltime isn&#8217;t going to help you. If you want to become a ladies man, you&#8217;ve got to start talking to women. If you want to become a doctor, reading about it won&#8217;t help you. Whatever it is, sitting at home won&#8217;t help you. </p>
<h2>Get To Work Son</h2>
<p>Remove yourself from the talker pool. From now on it&#8217;s either a <a href="http://sivers.org/hellyeah">Hell Yeah! or No</a>. Start doing what you talk about. Finish what you start. Nobody cares about your ideas. Nobody cares about your half finished product. They&#8217;ve seen this a thousand times, another guy with another goal who isn&#8217;t actually trying that hard.</p>
<p>Deciding on what language to use for a project? What person to talk to? <code>It doesn't matter.</code> Make quick decisions. If you made the wrong one, you&#8217;ll be able to tell pretty early on and you can go fix it easy enough. <a href="http://leostartsup.com/2012/03/make-the-decisions-you-take-the-ones-that-actually-count/">Make the decisions that actually matter.</a></p>
<p>You can read about a topic forever, but that doesn&#8217;t mean you can actually do it.</p>
<h3>Know when to stop reading and start doing.</h3>
<p>Reading only provides suggestions, you can&#8217;t know exactly what to learn until you start doing.</p>
<p>Do you catch yourself doing this too? How do you convince yourself to take action instead?</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/LjoGyrvv8Zw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/dont-tell-me-you-want-to-change-the-world-show-me/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/dont-tell-me-you-want-to-change-the-world-show-me/</feedburner:origLink></item>
		<item>
		<title>Rails Tip #7: Mass Assignment Security</title>
		<link>http://feedproxy.google.com/~r/excid3/~3/4tO199oNXis/</link>
		<comments>http://excid3.com/blog/rails-tip-7-mass-assignment-security/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 16:00:17 +0000</pubDate>
		<dc:creator>excid3</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://excid3.com/blog/?p=1470</guid>
		<description><![CDATA[I know everyone has been writing about this lately, so pardon yet another article on the pile, but this is a serious issue that people need to take into consideration daily. Since the recent Github fiasco, there has been a lot of talk about security on the web. This was an exceptional response on their [...]]]></description>
			<content:encoded><![CDATA[<p>I know everyone has been writing about this lately, so pardon yet another article on the pile, but this is a serious issue that people need to take into consideration daily.</p>
<p>Since the recent Github fiasco, there has been a lot of talk about security on the web. This was an <a href="https://github.com/blog/1068-public-key-security-vulnerability-and-mitigation">exceptional response</a> on their part, and something that every single one of us needs to take seriously instead of pointing fingers at people, companies, and frameworks.</p>
<p>Let&#8217;s dive into the vulnerability.</p>
<h2>Mass Assignment</h2>
<p>When you create a form in Rails, you&#8217;re effectively mapping form values to a hash:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= form_for <span style="color:#0066ff; font-weight:bold;">@post</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">text_field</span> <span style="color:#ff3333; font-weight:bold;">:title</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">text_area</span> <span style="color:#ff3333; font-weight:bold;">:content</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">if</span> current_user.<span style="color:#9900CC;">admin</span>? <span style="color:#006600; font-weight:bold;">%&gt;</span>
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">check_box</span> <span style="color:#ff3333; font-weight:bold;">:important</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&nbsp;
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">submit</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>This hash&#8217;s values get assigned to the attributes of the Rails model you&#8217;re creating:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Parameters: 
<span style="color:#006600; font-weight:bold;">&#123;</span> 
  <span style="color:#996600;">&quot;commit&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;Submit&quot;</span>, 
  <span style="color:#996600;">&quot;post&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#123;</span> 
    <span style="color:#996600;">&quot;title&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>;<span style="color:#996600;">&quot;First Post&quot;</span>, 
    <span style="color:#996600;">&quot;content&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>;<span style="color:#996600;">&quot;This is the content for the first post.&quot;</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>We access that in our controller&#8217;s create action:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<span style="color:#9900CC;">new</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span>        <span style="color:#008000; font-style:italic;"># THIS IS THE IMPORTANT LINE</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">save</span>
    redirect_to <span style="color:#0066ff; font-weight:bold;">@post</span>, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Successfully created.&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Update is affected as well</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> update
  <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<span style="color:#9900CC;">find</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">update_attributes</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span>      <span style="color:#008000; font-style:italic;"># ALSO USES THE PARAMS HASH</span>
    redirect_to <span style="color:#0066ff; font-weight:bold;">@post</span>, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Successfully updated.&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:edit</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>On line 2 here, the params are passed into the new Post object. That is where the submitted form data is assigned to the model and then saved to the database.</p>
<p><strong>And that&#8217;s where the problem lies.</strong></p>
<p>By default, a user can update any attributes. So if you decide to allow users to be &#8220;admins&#8221;, then removing a field in the form that is for admins only is not good enough. A user can still submit the admin only param without permission.</p>
<h2>The solution: <code>attr_accessible</code></h2>
<p>The solution for this is <code>attr_accessible</code>. This method tells your model which attributes can be assigned via hash like in the <code>create</code> action we saw earlier.</p>
<p>Let&#8217;s do this by example. Pretend we don&#8217;t want people updating the <code>:important</code> attribute on a Post. What do we do?</p>
<p>The first thing, is that we should require <code>attr_accessible</code> be on all of our models. In <code>application.rb</code>, uncomment this line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">active_record</span>.<span style="color:#9900CC;">whitelist_attributes</span> = <span style="color:#0000FF; font-weight:bold;">true</span></pre></div></div>

<p>This no longer allows any of the attributes on any models to be set through mass assignment. That&#8217;s good.</p>
<p>Now we have to update the model to allow certain attributes:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Post <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  attr_accessible <span style="color:#ff3333; font-weight:bold;">:title</span>, <span style="color:#ff3333; font-weight:bold;">:content</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>When you try to attack the site by sending over a <code>:important</code> attribute, it will simply be ignored now. This is exactly what we want.</p>
<p>Rails will throw an exception in development if a protected attribute is attempted to be set. In production, no exception will be raised, the attribute will juts be ignored. That&#8217;s a good start.</p>
<h2>What if we want some users to be able to set a protected attribute though?</h2>
<p>In our case, let&#8217;s say that we want admin users to be able to update the <code>:important</code> attribute. If attr_accessible doesn&#8217;t allow us to save <code>:important</code>, then how do we actually set it??</p>
<p>Let&#8217;s fix up the controller to allow this for users who are admins. We&#8217;ll be using Devise with a boolean <code>:admin</code> column on the user so that is where <code>current_user</code> will be coming from.</p>
<p>Let&#8217;s hop back in our controller and fix things up:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#008000; font-style:italic;"># Remove the insecure item(s) so we don't throw an exception in development</span>
  important = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">delete</span> <span style="color:#ff3333; font-weight:bold;">:important</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Create the new post as normal</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<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><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># If the user is allowed update this attribute, explicitly set it</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">important</span> = important <span style="color:#9966CC; font-weight:bold;">if</span> current_user.<span style="color:#9900CC;">admin</span>?
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">save</span>
    redirect_to <span style="color:#0066ff; font-weight:bold;">@post</span>, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Successfully created.&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:new</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Update is affected as well</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> update
  <span style="color:#008000; font-style:italic;"># Strip out the protected params so we don't throw exceptions in development</span>
  important = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">delete</span> <span style="color:#ff3333; font-weight:bold;">:important</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Grab the post as usual</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span> = Post.<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;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Set the attributes like we do in create</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">attributes</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Explicitly update the important attribute only if the user is an admin</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">important</span> = important <span style="color:#9966CC; font-weight:bold;">if</span> current_user.<span style="color:#9900CC;">admin</span>?
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@post</span>.<span style="color:#9900CC;">save</span>
    redirect_to <span style="color:#0066ff; font-weight:bold;">@post</span>, <span style="color:#ff3333; font-weight:bold;">:notice</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Successfully updated.&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    render <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:edit</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And this will allow any type of user to update the title and content attributes, but only admins are safely allowed to update the important field.</p>
<p>The important part to take note of here is that we are explicitly setting the protected attributes. We know <strong>exactly</strong> what we are doing when we want to set those attributes, so this (aside from logic problems) makes updating these attributes protected from mass assignment while still being usable.</p>
<p>Another important benefit of <code>attr_accessible</code> is that any new fields we add to the model are immediately protected. This whitelist approach makes sure that we have to declare fields as &#8220;safe&#8221; which leads to much fewer security holes when changing this code in the future because it forces you to not be forgetful.</p>
<h2>Conclusion</h2>
<p>This is certainly a feature that will be updated in the future versions of Rails. The current solutions aren&#8217;t exceptionally graceful, so I&#8217;m sure that we&#8217;ll see some nice improvements soon.</p>
<p>In the mean time, keep with whitelisting attributes, and if have a lot of dynamic attributes that depend on the user roles, check out dynamic <code>attr_accessible</code> on <a href="http://railscasts.com/episodes/237-dynamic-attr-accessible">Railscast 237</a>.</p>
<img src="http://feeds.feedburner.com/~r/excid3/~4/4tO199oNXis" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://excid3.com/blog/rails-tip-7-mass-assignment-security/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://excid3.com/blog/rails-tip-7-mass-assignment-security/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.824 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-17 19:33:05 -->

