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

<channel>
	<title>jc-designs.net &#187; ruby</title>
	<atom:link href="http://jc-designs.net/blog/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://jc-designs.net/blog</link>
	<description>jc-designs blog</description>
	<lastBuildDate>Mon, 21 May 2012 19:32:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ruby On Rails &#8211; A Beginners Journey &#8211; Part 1</title>
		<link>http://jc-designs.net/blog/2011/11/ruby-on-rails-a-beginners-journey-part-1/</link>
		<comments>http://jc-designs.net/blog/2011/11/ruby-on-rails-a-beginners-journey-part-1/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 03:47:04 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=1033</guid>
		<description><![CDATA[Let&#8217;s document my trip, shall we? I set myself a goal at the beginning of the year to learn Ruby by the end of it. Well, I finally started doing just that. Actually I&#8217;ve tried a couple of times, but didn&#8217;t get far into it. By starting with Rails this time, I am actually picking [...]]]></description>
			<content:encoded><![CDATA[<h3>Let&#8217;s document my trip, shall we?</h3>
<p>I set myself a goal at the beginning of the year to learn Ruby by the end of it. Well, I finally started doing just that. Actually I&#8217;ve tried a couple of times, but didn&#8217;t get far into it. By starting with Rails this time, I am actually picking up things a lot quicker. I&#8217;ll give all the credit to Michael Hartl, who wrote the book <a href="http://www.amazon.com/gp/product/0321743121/ref=s9_simh_gw_p14_d0_g14_i1?pf_rd_m=ATVPDKIKX0DER&#038;pf_rd_s=center-2&#038;pf_rd_r=0EBRTVQ9KDHS5F7NBCWY&#038;pf_rd_t=101&#038;pf_rd_p=470938631&#038;pf_rd_i=507846" title="Ruby on Rails 3 Tutorial on Amazon">Ruby On Rails 3 Tutorial</a>, which is what I am using, and so far recommend. You can also visit the site <a href="http://ruby.railstutorial.org/" title="Ruby on Rails 3 Tutorial website">here</a>. This isn&#8217;t a book review, though I might do later on. This post is the beginning of many that I&#8217;m going to use to document my progress. You know, show you where I was being stupid, and the awesome &#8220;ah-HA!&#8221; moments.</p>
<p><span id="more-1033"></span></p>
<h3>The beginning is the hardest</h3>
<p>I&#8217;m talking about setup here, not writing any code. There are a lot of things that I had to do before I could start typing anything that looked like Ruby. First came Rails. Installing Rails is actually the easiest part of it. I didn&#8217;t have any trouble there. </p>
<p>Then came Git. Had to download an install that, and there is a bunch of stuff you need to do to get that to work with <a href="http://github.com/" title="Github">github.com</a>. Be it the key you have to type in, create a repository, then do a test app and add the files, followed by commiting them, then pushing them&#8230;went on and on it seemed, but I got Git up and running. Go me!</p>
<p>Next came Heroku. A place to store your newly created app and view it online. Where Git is the version control, <a href="http://www.heroku.com/" title="Heroku Cloud Application Platform">heroku.com</a> is like the host. But in order for that to function right, you have to create an app space. Oh ya, install the Heroku gem by the way. Once you have the app space created, you then have to hook it up with Git, so you can use Git to push your app to Heroku. Luckily there is pretty good documentation for this stuff, so if anything goes wrong, which it will, you aren&#8217;t dead in the water.</p>
<p>Of course that doesn&#8217;t exactly mean everything will go smoothly.</p>
<h3>Rails&#8217; Gemfile is cool</h3>
<p>This is a file that Rails creates where you tell it what gems your app needs in order to work. I have had a little experience with gems before because of my use of Sass, and recently Haml. While going through this glorious book it tells you what gems to require, and how to add them. So simple in fact that I decided let&#8217;s add a few just to see if it really IS that easy. In went Sass, Haml, and Compass. Then of course, you must bundle all this crap together with the &#8220;bundle install&#8221; at the command line. Piece of cake!</p>
<p>That is until I tried getting everything in the tutorial to work with Heroku. You see, in the book it tells you to include this line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;color: #439AD0; font-weight: bold;">gem <span style="color:#996600;color: #439AD0;">'sqlite3-ruby'</span>, 1.2.5<span style="color:#996600;color: #439AD0;">', :require =&gt; '</span>sqlite3<span style="color:#996600;color: #439AD0;">'</span></pre></div></div>

<p>This gave me an error when I tried to push it to Heroku. Why? Easy! Heroku doesn&#8217;t support SQLite databases. FREAKIN&#8217; awesome. I then spent a long time figuring this crap out until a friend sent me to <a href="http://stackoverflow.com/questions/3897431/deploying-ror-app-to-heroku-with-sqlite3-fails" title="Heroku sqlite3 fix">Stack Overflow</a> for the fix. The funny part was that I had already seen that article and I swear I tried the solution. Apparently not though, because putting this in my Gemfile instead, worked:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;color: #439AD0; font-weight: bold;">group <span style="color:#ff3333; font-weight:bold;">:production</span>, <span style="color:#ff3333; font-weight:bold;">:staging</span> <span style="color:#9966CC; font-weight:bold;color: #439AD0;">do</span>
  gem <span style="color:#996600;color: #439AD0;">&quot;pg&quot;</span>
<span style="color:#9966CC; font-weight:bold;color: #439AD0;">end</span>
&nbsp;
group <span style="color:#ff3333; font-weight:bold;">:development</span>, <span style="color:#ff3333; font-weight:bold;">:test</span> <span style="color:#9966CC; font-weight:bold;color: #439AD0;">do</span>
  gem <span style="color:#996600;color: #439AD0;">&quot;sqlite3-ruby&quot;</span>, <span style="color:#996600;color: #439AD0;">&quot;~&gt; 1.3.0&quot;</span>, :<span style="color:#CC0066; font-weight:bold;color: #439AD0;">require</span> <span style="color:#006600; font-weight:bold;color: #439AD0;">=&gt;</span> <span style="color:#996600;color: #439AD0;">&quot;sqlite3&quot;</span>
<span style="color:#9966CC; font-weight:bold;color: #439AD0;">end</span></pre></div></div>

<p>Everything then was handy dandy for a while. Until I added the Blueprint framework CSS and tried to push it to Heroku. Some error about the SCSS file not precompiled. Again I had to go and search Google&#8217;s pages to find the answer, which was to change a line to this:</p>

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

<h3>I&#8217;m told testing is good!</h3>
<p>Test-driven development is good according to this book. From what I know now, that is probably a good thing to get into the habit of. This led to installing rspec, which places files in Rails and lets your write test to see if things are working properly. Is the correct title showing up on the right page? Good. No? Fix it. Well, installing rspec was fine, but running my first test popped up an error about something or other. All I remember is having to install something called ANSICON v1.40. Can&#8217;t remember what it does, but that it was being asked for.</p>
<p>From rspec install, to first test, to installing ANSICON, to test again was probably about 40 minutes of time. Not terrible, but when you start adding all this stuff up and realize I haven&#8217;t actually done anything yet, you start to think that this isn&#8217;t as simple as you were hoping. Ruby might be an easy language to read, but getting all this crap going is a serious pain in the ass.</p>
<h3>Actually learning something&#8230;priceless</h3>
<p>At work I sometimes have to dive into the folder structure of Symfony, which is a framework for PHP. Never liked it. Finding crap was a pain because I could never remember where certain things were placed. Learning Rails though has cleared some things up a little. I now understand MVC a bit more. What the hell is MVC? Good question.</p>
<p>It stands for Model View Controller. The Model is what talks to the database. The Controller tells the View what to display and gives/takes things from the View to relate back to the Model. They really need to come out with a book for noobs explaining all the vocabulary in plain terms. Rails provides folders actually called: models, views, and controllers, so you actually get this stuff buried in your brain some.</p>
<h3>I see the power of Haml more clearly</h3>
<p>Within the folder structure you have a file that makes me think of &#8220;template&#8221;, called &#8216;application.html.erb.&#8217; Which now that I just looked it up, apparently IS a templating system, just not as cool as Haml. You can go read my <a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/" title="Intro to Haml Part 1" target="_blank">four part series on Haml</a> at your leisure. One thing that really became apparent though is how perfect a fit Haml is with Rails. Rails seems to be about building things quickly and easy to read (due to Ruby), and Haml just adds to that. Now add in Sass? Holy F*$# this is getting exciting. I wish I didn&#8217;t feel so late to the party.</p>
<h3>A good but difficult start</h3>
<p>Well now, it looks like it is going to be a long trip. So far I feel like I have learned a lot, while at the same time having a voice in the back of my head telling me I&#8217;m not grasping all of it. Maybe it will take me a couple of passes through this book, who knows. What I do know is that I am having fun learning this, and that has kind of been missing for a little while. I need something to dig into, and Rails/Ruby seem to finally be it for me.</p>
<p>This is not a subject that the average front end developer is going to like unless you have been looking to get into a programming language. Most I know, have no desire to actually do that. A major barrier with Rails though, at least for the inexperienced, is the amount of time you spend using the command line and fixing problems just to get everything running smooth. So much depends on what version of whatever it is you are using, which can cause so many problems. If you add up all the time I spent just trying to get to the &#8220;Ok, NOW I can start writing crap&#8221; moment, most people would have given their computer the finger and said screw it. This is even more infuriating due to my book saying stupid crap like &#8220;If that doesn&#8217;t work, try using version 1.2.5. Beyond that use Google.&#8221; Ok, not that exactly, but really freaking close.</p>
<p>Anyway, I will write about my progress as I go along and learn or come upon. This is basically what I started this blog for almost two years ago. To show what I&#8217;ve learned and what bugged or created difficulty for me.</p>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1033" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/11/ruby-on-rails-a-beginners-journey-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Haml For HTML Layouts for Newbs &#8211; Part 2: Writing Haml</title>
		<link>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-2-writing-haml/</link>
		<comments>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-2-writing-haml/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 18:08:17 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Haml]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=995</guid>
		<description><![CDATA[The difference between structure and content Haml is great! But for what, is the real question. According to Haml&#8217;s website, &#8220;Markup should be beautiful.&#8221; It definitely does make things look clean and easy to read, but there seems to be a catch. Chris Eppstein (creator of Compass) wrote an article that basically says don&#8217;t use [...]]]></description>
			<content:encoded><![CDATA[<h3>The difference between structure and content</h3>
<p>Haml is great! But for what, is the real question. According to <a href="http://haml-lang.com/" title="Haml language">Haml&#8217;s</a> website, &#8220;Markup should be beautiful.&#8221; It definitely does make things look clean and easy to read, but there seems to be a catch. Chris Eppstein (creator of Compass) wrote an <a href="http://chriseppstein.github.com/blog/2010/02/08/haml-sucks-for-content/" title="Haml Sucks for Content">article</a> that basically says don&#8217;t use Haml for content, and I suggest reading it when you are done reading this. Looking at his first example, which I won&#8217;t duplicate here, you see what he is driving at right away. For the actual content of the site, Haml starts to look like garbage. What it IS good for though, is the actual structure of the template. Template, file, whatever. The stuff you write in HTML, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;luckDragon&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>Haml can do better:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">#luckDragon</pre></div></div>

<p>The lesson to be learned here is that, for the main layout of your site use Haml. For the fluff we&#8217;ll use something called Markdown, which I&#8217;ll talk about in Part 3 of this series. In this post, we are going to deal with the basics of Haml though.</p>
<p><span id="more-995"></span></p>
<h3>Haml&#8217;s syntax</h3>
<p>The first part you need in an HTML file is the doctype, and while there are many you can use (which you can see <a href="http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#doctype_" title="Haml syntax for doctypes">here</a>), I am going to use the HTML5 version. The doctype is written out with three exclamation points, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">!!!5</pre></div></div>

<p>Which will give you this HTML output:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;!DOCTYPE html&gt;</pre></div></div>

<p>Pretty sweet, because I am all about eliminating as many characters as possible, so I can get my work done faster. Haml does this with almost everything.</p>
<p>After that, things are pretty straight forward. Elements start with a &#8220;%&#8221;, id&#8217;s start with a &#8216;#&#8217;, class starts with a &#8216;.&#8217;. What is really badass is that Haml defaults id&#8217;s and classes to render as a &#8216;div&#8217; in the HTML output file, unless you specify otherwise. Let&#8217;s take a look some basic syntax in an actual example:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">!!! 5
%html
	%head
		%title Stasis - Static Sites Made Powerful
		%link{ :href =&gt; &quot;stasis.css&quot;, :media =&gt; &quot;screen&quot;, :rel =&gt; &quot;stylesheet&quot;, :type =&gt; &quot;text/css&quot; }
	%body
		#container
			%nav
				%ul
					%li
						%a{:href=&gt; &quot;#&quot;} Home
					%li
						%a{:href=&gt; &quot;#&quot;} Services
					%li
						%a{:href=&gt; &quot;#&quot;} About Us
					%li
						%a{:href=&gt; &quot;#&quot;} Blog
					%li
						%a{:href=&gt; &quot;#&quot;} Contact Us
			#content</pre></div></div>

<p>If you have followed along so far, you can easily see what is going on here. Everything with a &#8216;%&#8217; symbol in front of it, is an element. Everything with a &#8216;#&#8217; in front of it is a div tag with an id. Once you render this into the HTML file, this is what you get:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Stasis - Static Sites Made Powerful&lt;/title&gt;
    &lt;link href='stasis.css' media='screen' rel='stylesheet' type='text/css' /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id='container'&gt;
      &lt;nav&gt;
        &lt;ul&gt;
          &lt;li&gt;
            &lt;a href='#'&gt;Home&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href='#'&gt;Services&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href='#'&gt;About Us&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href='#'&gt;Blog&lt;/a&gt;
          &lt;/li&gt;
          &lt;li&gt;
            &lt;a href='#'&gt;Contact Us&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/nav&gt;
      &lt;div id='content'&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Now I know what you are thinking. Yes, the HTML is not formatted the way you would like it to be, but there are options in changing that, which I won&#8217;t get into right now. For now, just accept it and move along. In reality, if you are using Haml, the actual HTML is not what you are going to be working with. You would use the &#8216;.haml&#8217; file. That is the point here. </p>
<p>Moving forward now, so keep up. If you really looked at the example I used above, you will see something I didn&#8217;t mention, and that is an element&#8217;s attributes. Not that big of a deal, it&#8217;s just markup you wouldn&#8217;t recognize if you haven&#8217;t seen Ruby. After the element you are going to put the &#8216;{}&#8217; in, and between that are the attributes. If you have multiple, they are seperated by a comma, and each attribute starts with a colon. The odd part you will most likely forget without looking the first few times is the &#8216;=>&#8217;. I look at it as the attribute pointing to the value it is supposed to be. That could have been the intention, but what the hell do I know. Here is what the link to a css file would look like though:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">%a{:href=&gt; &quot;#&quot;} Home</pre></div></div>

<p>Which outputs this HTML:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;a href='#'&gt;Home&lt;/a&gt;</pre></div></div>

<h3>Indentation matters, so pay attention!</h3>
<p>Yes, Haml pays attention to how you indent your markup. You probably already do this kind of thing in your normal HTML when you nest your div tags, but it isn&#8217;t required. Forget to indent at the right place using Haml, and you could get an error when you try to render it into HTML. In the following example, you will see Haml&#8217;s markup for the HTML5 doctype:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">!!! 5
%html</pre></div></div>

<p>The above is correct, but if you tabbed over the &#8216;%html&#8217;, which renders as the &#8216;html&#8217; tag, you will get the error: &#8220;Illegal nesting: nesting within a header command is illegal.&#8221; This is because Haml treats the indent as if you were nesting the &#8216;html&#8217; tag within the doctype.</p>
<p>Now, if you indented an element over twice (2 tabs) from its parent, you would get an error that says something like &#8220;The line was indented 2 levels deeper than the previous line.&#8221; If you ever get an error like this, you know what your problem is. Indenting is extremely important because it shows Haml how to structure everything. If it is tabbed over from the element above it, that element becomes nested within. Seriously, this is important if you are going to be using Haml.</p>
<h3>Rendering Haml into HTML</h3>
<p>Two methods really. The regular way, and the way Stasis does it if you have that all loaded and ready from the previous post. I&#8217;ll show you both though, just in case.</p>
<p>Using Stasis: at the command line, cd to the directory your file is in (index.html.haml) and type:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ stasis -o index.html.haml</pre></div></div>

<p>This will output an HTML file in the public folder named &#8216;index.html&#8217;.</p>
<p>Just using Haml, in the command line, cd to your project folder, and type:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ haml index.haml index.html</pre></div></div>

<p>The first file (index.haml) is obviously your Haml file, while the second is what you want the output file to be called (index.html in this case).</p>
<p>Either way is easy, you just don&#8217;t have to go through all that install crap that I went through in my <a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/" title="Introduction to Haml For HTML Layouts For Newbs – Part 1: Installing Stasis" target="_blank">first post in this series</a>. I was using <a href="http://stasis.me/" title="Ruby Gems - Stasis">Stasis</a> because I might be using its options later.</p>
<h3>Final thoughts</h3>
<p>I REALLY like Haml for its simplicity, and almost as much as I love Sass. You become aware of things pretty quickly once you start using it, such as indentation being key to writing your structure. I think the best part of writing your layout using this, is that the basics are learned quickly. Once you have it down, writing the main structure becomes a breeze. I should also point out that while you are using Haml&#8217;s syntax, you can also inject HTML into it just like normal. Seems kind of pointless, but the option is there. </p>
<h3>What&#8217;s next?</h3>
<p>Since Haml is not great for writing the actual content of the site, the third post in this series will deal with <a href="http://daringfireball.net/projects/markdown/" title="Markdown syntax">Markdown</a>. It is a plain text formatting syntax that you can use within Haml, and makes writing the content easier.</p>
<p>Hope you learned something today, so leave a comment and let me know!</p>
<p><strong>Artilces in this series</strong>:</p>
<ul>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/" title="Intro to Haml Part 1">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 1: Installing Stasis</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-2-writing-haml/" title="Intro to Haml Part 2 - Writing Haml">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 2: Writing Haml</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-3-markdown-syntax-for-content/" title="Intro to Haml Part 3 - Markdown Syntax for Content">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 3: Markdown Syntax For Content</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-4-final-thoughts/" title="Intro to Haml Part 4 - Final Thoughts">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 4: Final thoughts</a></li>
</ul>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=995" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-2-writing-haml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introduction to Haml For HTML Layouts For Newbs &#8211; Part 1: Installing Stasis</title>
		<link>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/</link>
		<comments>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 01:51:07 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Haml]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=983</guid>
		<description><![CDATA[Part one of four Learning something new is awesome, and writing about what I am learning helps me get it into my head a lot more. Yesterday I started learning how to use Haml, and once I started, I thought I would pass on this newly acquired knowledge on to you. This series is for [...]]]></description>
			<content:encoded><![CDATA[<h3>Part one of four</h3>
<p>Learning something new is awesome, and writing about what I am learning helps me get it into my head a lot more. Yesterday I started learning how to use Haml, and once I started, I thought I would pass on this newly acquired knowledge on to you. This series is for NON programmers. You might know javascript/jQuery, but the people I am writing this for are not really going to have any real knowledge of programming. If you have just gotten into using Sass, then this is a perfect next step for you. Here are the topics in this four part series:</p>
<ul>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/" title="Intro to Haml Part 1">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 1: Installing Stasis</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-2-writing-haml/" title="Intro to Haml Part 2 - Writing Haml">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 2: Writing Haml</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-3-markdown-syntax-for-content/" title="Intro to Haml Part 3 - Markdown Syntax for Content">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 3: Markdown Syntax For Content</a></li>
<li><a href="http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layouts-for-newbs-part-4-final-thoughts/" title="Intro to Haml Part 4 - Final Thoughts">Introduction to Haml For HTML Layouts for Newbs &#8211; Part 4: Final thoughts</a></li>
</ul>
<p><img class="right" src="http://www.jc-designs.net/newimages/blogImages/haml.gif" alt="Haml logo" />So what the hell is Haml anyway? Well, imagine taking out the syntax of an HTML document, and replacing it with a cleaner syntax. It also adds a ton of other functionality, but what I&#8217;m going to be talking about in this series is just basic HTML layout writing. Mainly because I just got started with it myself, so the other stuff will have to wait.<br />
<span id="more-983"></span></p>
<h3>Let&#8217;s install Stasis</h3>
<p>I have been wanting to use Haml (a Ruby gem) for a long time now, but I didn&#8217;t know how to go about doing it. If you are not familiar with the command line or Ruby, things like this are intimidating.  Thanks to another Ruby gem, called <a href="http://stasis.me/">Stasis</a>, I was finally able to get a Haml file rendered into an HTML file and finally get started with seeing what it is all about. I love learning new things, so thank you to <a href="http://twitter.com/smashingmag" title="SmashingMagazine's Twitter feed">SmashingMagazine</a> for tweeting about it yesterday. Who would have thought they would be the ones to let me know about this? </p>
<div class="center">
<img src="http://jc-designs.net/newimages/blogImages/stasis.jpg" alt="Stasis logo" />
</div>
<p>First, we need to get a few things installed. Most importantly, Stasis, but even before that, we need to make sure we have a few things done. Open your command line and make sure your Ruby Gems are updated (it&#8217;s probably just a good idea to do so):</p>
<p><em>NOTE: the &#8216;$&#8217; seems to be a universal thing when showing that you are writing a command line instruction. No idea why, but I&#8217;ll use it as well. Just note that you do <strong>NOT</strong> type the &#8216;$&#8217; in the command line.</em></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ gem update --system</pre></div></div>

<p>Then install Haml:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ gem install haml</pre></div></div>

<p>That was the easy part. Now onto the annoying crap. I had to install a bunch of gems to get stasis to work, and while I am not sure which ones are required, I recommend doing all of them at the same time. The one I know you need for certain, is the <a href="http://rubyinstaller.org/downloads/" title="Get the Ruby DevKit installer">Ruby DevKit</a>. Go there, download it, extract it (I did it straight to my C: drive), and then go to the command line, change directories until you are at the location of where you put the DevKit, and type:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ ruby dk.rb init</pre></div></div>

<p>After you get the confirmed initialized message, type this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ ruby dk.rb install</pre></div></div>

<p>Now, it might just work after that, but mine was still having issues, so I went to the <a href="http://rubygems.org/gems/stasis" title="Ruby Gems - Stasis">Stasis page</a> on the Ruby Gems website and installed everything that was listed at the bottom:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ gem install directory_watcher
$ gem install redis
$ gem install slop
$ gem install tilt
$ gem install yajl-ruby
$gem install rake
$gem install rspec</pre></div></div>

<p>I&#8217;m guessing you don&#8217;t need all of that, but it didn&#8217;t hurt. Once you have all of THAT done, NOW you can install Stasis:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ gem install stasis</pre></div></div>

<h3>Start a new project</h3>
<p>Now that you have Stasis installed, go and create a folder to test all this crap in. Create a new file and save it as &#8216;index.html.haml&#8217; using a text editor (Notepad++ for me!), within that folder. Next, go back to the command line and change directories until you are in that folder, then:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">$ stasis</pre></div></div>

<p>This should place a folder within the one you created, called &#8216;public&#8217;. In it, you will see a file called &#8216;index.html&#8217;. </p>
<h3>Can I use Haml now? Please?</h3>
<p>YES! Just not in this post. I&#8217;ve probably already went beyond your capacity to really pay attention to me anymore, so you shall have to wait until the next post!  I&#8217;ll let you see a hint of what Haml is all about though.</p>
<p>What you might write in HTML</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;container&quot;&gt;
    &lt;p&gt;This is typical crap.&lt;/p&gt;
&lt;/div&gt;</pre></div></div>

<p>The same thing, but written in Haml:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">#container
    %p This is typical crap.</pre></div></div>

<h3>So what will we be learning in the next post?</h3>
<p>The fun stuff of course. Haml&#8217;s basic syntax as I walk you through how to write up a standard static web page. The third post will be on writing the content (what you read on the site) using Markdown syntax, and putting it within Haml. The final post in the series will be my thoughts on all of it combined. </p>
<p>If any pros have an easier way to just use Haml (and quickly), I&#8217;d love to hear it!</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=983" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/09/introduction-to-haml-for-html-layout-for-newbs-part-1-installing-stasis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby And Learning It From An Idiot&#8217;s Perspective</title>
		<link>http://jc-designs.net/blog/2010/10/installing-ruby-and-learning-it-from-an-idiots-perspective/</link>
		<comments>http://jc-designs.net/blog/2010/10/installing-ruby-and-learning-it-from-an-idiots-perspective/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 05:55:55 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=624</guid>
		<description><![CDATA[Picking A Programming Language I&#8217;ve hemmed and hawed over what programming language to learn, and was pretty much settled on PHP&#8230;just never got around to learning it. I have put PHP on the side burner for now, because it became obvious on what I should try to pick up. I&#8217;m already using Sass, which is [...]]]></description>
			<content:encoded><![CDATA[<h3>Picking A Programming Language</h3>
<p>I&#8217;ve hemmed and hawed over what programming language to learn, and was pretty much settled on PHP&#8230;just never got around to learning it. I have put PHP on the side burner for now, because it became obvious on what I should try to pick up. I&#8217;m already using Sass, which is a part of Haml, which is a gem&#8230;.of Ruby. Might as well learn the parent of what I am already starting to use. So, no brainer for me. Is it for you? How the hell would I know? But I&#8217;ll tell you my experience so far, which isn&#8217;t much.</p>
<h3>The Scary Part &#8211; Installing it!</h3>
<p><strong>NOTE: For people on a PC only as I have no experience doing this on a Mac or Linux machine.</strong><br />
Now that I have installed Ruby three separate times, it has become less intimidating than it was when I first did it. If you are interested in learning Ruby, but have a slight fear in diving in head first, let me tell you what you need to know without all the bullcrap and non-helpful documentation you will read. Ready? Here we go:</p>
<p><span id="more-624"></span></p>
<ul>
<li><a href="http://www.ruby-lang.org/en/downloads/">Download Ruby</a> &#8211; You want the one under &#8216;Ruby on Windows&#8217;, and the link that says &#8220;Ruby 1.9.2-p0 RubyInstaller&#8221;</li>
<li>Double click the .exe file that downloaded onto your machine.</li>
<li>IMPORTANT: Look at the graphic below, when you get to the screen that shows that, MAKE SURE BOTH OF THOSE CHECK BOXES ARE CHECKED</li>
</ul>
<div class="center">
<img src="http://www.jc-designs.net/newimages/blogImages/ruby1.jpg" alt="Ruby installer window" />
</div>
<p>Do that and you are fine. Without those checked, I could not run Ruby from any directory. Took me a couple of re-installs to figure that out. Congrats, Ruby is installed! Now you might as well get the rest of the crap out of the way. I haven&#8217;t gotten into Rails yet, but it seems like that is the framework of choice. Let&#8217;s do that next:</p>
<ul>
<li>Follow this link to <a href="http://rubyonrails.org/download">RubyForge</a></li>
<li>Look where it says RubyGems, click the download button, and download one of the 1.3.7 files</li>
<li>Extract/unzip (whatever) the file</li>
<li>Click on the Windows Icon/Start thing, and type &#8216;cmd&#8217;</li>
<li>Navigate to the directory for it (for me it was:C:\Users\Jeremy\Desktop\rubygems-1.3.7\rubygems-1.3.7<br />
- note that to change to a directory you type &#8216;cd&#8217; and the directory name &#8211; &#8216;cd Desktop&#8217; &#8211; to go back a directory you type &#8216;cd..&#8217;</li>
<li>Type &#8216;ruby setup.rb&#8217; in the command line</li>
<li>When it is finished, type &#8216;gem update&#8217; just to make sure</li>
<li>Type &#8216;gem install rails&#8217;</li>
</ul>
<p>Let&#8217;s install Haml/Sass and Compass while we are at it.</p>
<ul>
<li>Type &#8216;gem install haml&#8217;</li>
<li>Type &#8216;gem install compass &#8211;pre&#8217;</li>
</ul>
<p>Now get up, go grab a beer and watch some SAMCROW cause that was nuts, wasn&#8217;t it? Not for newbs, and not for idiots like me. It took me a silly amount of time to get this down.</p>
<h3>Is Ruby the language Written For Front End Developers?</h3>
<p>What makes Ruby appealing to me, over say learning PHP or any other language is that at first glance it seems to be &#8216;coding for dummies.&#8217; Why is that, you ask? Because if you have ever looked at PHP code, you will see a lot of extra syntax. Commas, quotes, dollar signs&#8230;a ton of stuff like that. In Ruby, a lot of that crap is gone. I want to assign my name to a variable it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">name = &quot;Jeremy&quot;</pre></div></div>

<p>I want it to be all uppercase? Fine and dandy&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">name.upcase</pre></div></div>

<p>That simplicity is what attracts me to Ruby, which is probably the same reason I like jQuery. I want a language that is clean and easy to write&#8230;and remember. The learning curve seems way lower than something like PHP, and that appeals to me, because I want to learn it quickly. Just looking at beginning examples seems like Ruby is almost an abstraction of a different language. Like someone said, let&#8217;s take PHP and take out all the crap. Now, I have no real authority to say that is actually what happened, but that is the feeling I get when I look at sample code. </p>
<p>What I am curious about, is how everything ties together to actually make a site using it. The time spent learning Ruby in the beginning seems to be dedicated to actually learning the language itself, which is what the book I have bought recently, is doing. A &#8220;here&#8217;s how to do stuff&#8221;, and then followed later by &#8220;Now that you know what you are doing, let&#8217;s do it.&#8221; Now, you might say, ya all languages do that, but Ruby is different. I can&#8217;t exactly write some code and then preview it in a browser. At least, I don&#8217;t know about it yet if there is. The whole experience so far has been &#8220;Let&#8217;s write out some code in the &#8216;irb&#8217; (&#8220;Interactive Ruby Shell&#8221; &#8211; which is just typing some Ruby out in the command line to see if it works. So if you expect to type some crap and see the fruits of your labor displayed in its greatness in a web browser, you are going to be disappointed.</p>
<p>The real question though is, because of its&#8230;level of abstraction feel, is it a better language for non-programmers (at the moment) to learn first over something like PHP? It sure seems that way because of the learning curve. I fear I am trying to learn Ruby because of that factor, instead of it being the better solution in coding. I&#8217;m not all that sure what the advantages/disadvantages are, but half the fun is going to be finding out. Hopefully I am making a good choice in picking Ruby, and if not, I hope I find out quickly.</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=624" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/10/installing-ruby-and-learning-it-from-an-idiots-perspective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby and Sass&#8230;.help me?</title>
		<link>http://jc-designs.net/blog/2010/04/ruby-and-sass-help-me/</link>
		<comments>http://jc-designs.net/blog/2010/04/ruby-and-sass-help-me/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 03:23:34 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sass]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=267</guid>
		<description><![CDATA[So I read a few articles lately, and I&#8217;ve seen this stuff before, but now I am really interested. Anyone out there wanna comment on Ruby? The syntax seems easy enough to learn, and I have heard it can be used to create things very quickly. I have also heard by some IT people I [...]]]></description>
			<content:encoded><![CDATA[<p>So I read a few articles lately, and I&#8217;ve seen this stuff before, but now I am really interested. Anyone out there wanna comment on Ruby? The syntax seems easy enough to learn, and I have heard it can be used to create things very quickly. I have also heard by some IT people I know that though it can be quick to create, which is good for prototyping, but hard to change. I&#8217;m looking for the run down on why I would want to look at Ruby. And is Rails the same thing? Help coders!</p>
<p>I&#8217;m interested in it because of Sass and what you can do with CSS. Here are just some examples I&#8217;ve seen with what you can do with Sass (Syntactically Awesome Stylesheets).</p>
<p>Variables:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;">!<span style="color: #000000; font-weight: bold;color: #439AD0;">blue</span> <span style="color: #00AA00;color: #439AD0;">=</span> <span style="color: #cc00cc;">#3bbfce</span>
&nbsp;
<span style="color: #6666ff;color: #439AD0;">.content_navigation</span>
  <span style="color: #000000; font-weight: bold;color: #439AD0;">border-color</span> <span style="color: #00AA00;color: #439AD0;">=</span> !<span style="color: #000000; font-weight: bold;color: #439AD0;">blue</span></pre></div></div>

<p>And this looks just plain awesome:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #6666ff;color: #439AD0;">.highlight</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
  <span style="color: #000000; font-weight: bold;color: #439AD0;">border</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">1px</span> <span style="color: #cc00cc;">#666666</span> <span style="color: #993333;color: #439AD0;">solid</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.moreHighlight</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
  <span style="color: #a1a100;color: #439AD0;">@extend .highlight;</span>
  <span style="color: #000000; font-weight: bold;color: #439AD0;">background-color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#ff0000</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<p>From what I&#8217;ve read, this means that anything with the style of moreHighlight also gets the styles of highlight. There are other things like Mixins and such that look bad ass as well.</p>
<p>What I&#8217;m curious about though, is it looks like it is compiled. Does this mean I have to do something every time I make a change to the file? Meaning re-compile it? Again, help me out!</p>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=267" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/04/ruby-and-sass-help-me/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

