<?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>Bloggeh.com &#187; Ruby on Rails</title>
	<atom:link href="http://www.bloggeh.com/tag/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bloggeh.com</link>
	<description>Bits and pieces</description>
	<lastBuildDate>Thu, 03 Feb 2011 04:01:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails Helpers</title>
		<link>http://www.bloggeh.com/2010/05/17/rails-helpers/</link>
		<comments>http://www.bloggeh.com/2010/05/17/rails-helpers/#comments</comments>
		<pubDate>Mon, 17 May 2010 13:04:33 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=221</guid>
		<description><![CDATA[Helpers are functions used in views.
If a helper corresponds to a specific controller, you should put it in the corresponding helper file. For example, helpers for the Pages controller generally go in app/helpers/pages.helper.rb. 
If the helper is going to be used on all a sites pages then the helper file to use is app/helpers/application.helper.rb.
In the [...]]]></description>
			<content:encoded><![CDATA[<p>Helpers are functions used in views.</p>
<p>If a helper corresponds to a specific controller, you should put it in the corresponding helper file. For example, helpers for the Pages controller generally go in <code>app/helpers/pages.helper.rb</code>. </p>
<p>If the helper is going to be used on all a sites pages then the helper file to use is <code>app/helpers/application.helper.rb</code>.</p>
<p>In the helper file:<br />
<code><br />
def title<br />
    base_title = "Ruby on Rails Tutorial Sample App"<br />
  if @title.nil?<br />
    base_title<br />
  else<br />
    "#{base_title} | #{@title}"<br />
  end<br />
end<br />
</code></p>
<p>In the view:<br />
<code><%= title %></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/17/rails-helpers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heroku for Deployment</title>
		<link>http://www.bloggeh.com/2010/05/05/heroku-for-deployment/</link>
		<comments>http://www.bloggeh.com/2010/05/05/heroku-for-deployment/#comments</comments>
		<pubDate>Wed, 05 May 2010 01:38:22 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=202</guid>
		<description><![CDATA[Setup an account at Heroku
Create a new application at Heroku
$ heroku create
Deploy your app
$ git push heroku master
Open your app
$ heroku open
Rename your subdomain
heroku rename appnamehere
]]></description>
			<content:encoded><![CDATA[<p>Setup an account at <a href="http://www.heroku.com">Heroku</a></p>
<p>Create a new application at Heroku<br />
<code>$ heroku create</code></p>
<p>Deploy your app<br />
<code>$ git push heroku master</code></p>
<p>Open your app<br />
<code>$ heroku open</code></p>
<p>Rename your subdomain<br />
<code>heroku rename appnamehere</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/05/heroku-for-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git</title>
		<link>http://www.bloggeh.com/2010/05/04/rails-tutorial-notes/</link>
		<comments>http://www.bloggeh.com/2010/05/04/rails-tutorial-notes/#comments</comments>
		<pubDate>Tue, 04 May 2010 13:04:33 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[railstutorial]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=182</guid>
		<description><![CDATA[Git is a version control system which allows you to track changes to projects code amongst many other things.
First-time system setup
Do these steps once per computer.
Head over to Installing Git section of Pro Git and install Git.
$ git config --global user.name "Your Name"
$ git config --global user.email youremail@example.com
$ git config --global core.editor "mate -w"
(this last [...]]]></description>
			<content:encoded><![CDATA[<p>Git is a version control system which allows you to track changes to projects code amongst many other things.</p>
<h2>First-time system setup</h2>
<p>Do these steps once per computer.</p>
<p>Head over to <a href="http://progit.org/book/ch1-4.html">Installing Git section of Pro Git</a> and install Git.</p>
<pre name="code" class="css">$ git config --global user.name "Your Name"
$ git config --global user.email youremail@example.com
$ git config --global core.editor "mate -w"</pre>
<p>(this last line is if you&#8217;re using textmate)</p>
<h2>Setting up a NEW Repository for your App</h2>
<p>Generally you will setup a repository for each application you create.</p>
<h2>1. Initalize the repository</h2>
<p><code>$ git init<br />
Initialized empty Git repository in /Users/username/rails_apps/first_app/.git/</code></p>
<h2>2. Add the project files to the repository (but ignore some first!)</h2>
<p>By default Git tracks the changes of <em>all</em> files, but there are some we don&#8217;t want to track. For example, the log files. We ignore files by including a file named <code>.gitignore</code> in the Rails root directory. Generate this file using your text editor and here&#8217;s a sample of what you might put in it.</p>
<p><code>log/*.log<br />
tmp/*<br />
tmp/**/*<br />
doc/api<br />
doc/app<br />
db/*.sqlite3<br />
*.swp<br />
*~<br />
.DS_STORE</code></p>
<p>Now we may add files to Git.<br />
<code>$ git add .</code></p>
<p>The dot &#8216;.&#8217; represents the current directory and Git is smart enough to add the files recursively so it automatically adds all subdirectories. This places the projects files in a <em>staging area</em>. You can see what files are in the staging area using the <code>status</code> command.<br />
<code>$ git status</code></p>
<h2>3. Committing files to the repository</h2>
<p>To tell Git you want to keep the changes in the staging area, use the <code>commit</code> command.<br />
<code>$ git commit -m "Initial commit"</code></p>
<p>The <code>-m</code> lets you add a message for the commit.</p>
<p><strong>Remember, Git commits are <em>local</em>, recorded only on the machine on which the commits occur.</strong></p>
<p>To push the changes to a remote repository you must use <code>git push</code>.</p>
<h2>Branch, Edit, Commit, Merge</h2>
<p>When making changes to an application use this process.</p>
<h2>1. Checkout a Branch</h2>
<p><code><br />
$ git checkout master<br />
$ git checkout -b 'branch name'</code></p>
<p>Notice the <code>-b</code> flag for checking out a branch. The first line just ensures we are branching from the master.</p>
<p><code>git branch</code> will list all the local branches, with an asterix identifying which branch we&#8217;re currently on.</p>
<h2>2. Edit</h2>
<p>Edit your files as required.</p>
<h2>3. Commit</h2>
<p>If you&#8217;ve added new files make sure you use <code>git add .</code> prior to doing a commit. Otherwise you may use the <code>-a</code> flag with your commit if you&#8217;ve modified existing files.<br />
<code> $ git commit -a -m "comment goes here"<br />
</code></p>
<h2>4. Merge</h2>
<p>When finished making changes, you merge these back to your master branch.<br />
<code>$ git checkout master<br />
Switched to branch 'master'<br />
$ git merge modify-README </code></p>
<p>Change modify-README to the name of your branch.<br />
Afterwards you can tidy up your branches by deleting the topic branch.<br />
<code> $git branch -d modify-README</code></p>
<h2>Push your changes to a remote repository</h2>
<p>Use the <code>push</code> command<br />
<code>$ git push</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/04/rails-tutorial-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Ruby and Rails Notes</title>
		<link>http://www.bloggeh.com/2010/05/03/learning-ruby-and-rails-notes/</link>
		<comments>http://www.bloggeh.com/2010/05/03/learning-ruby-and-rails-notes/#comments</comments>
		<pubDate>Mon, 03 May 2010 04:55:50 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=174</guid>
		<description><![CDATA[Strings
Strings are surrounded in quotes. For example, "David" is a string.
A complete list of Ruby string methods is here.
.reverse
"David".reverse
>> "divaD"
.length
"David".length
>> 5
.strip
Removes white space around a string.
"David  ".strip
>> "David"
multiplication
"David" * 5
>> "DavidDavidDavidDavidDavid"
Converting Object Types
.to_s &#8211; converts to strings
.to_i &#8211; converts to integers
.to_a &#8211; converts to arrays
Arrays / Lists
Use brackets [].
[12, 47, 35]
.max
[12, 47, 35].max
>> 47
Hash [...]]]></description>
			<content:encoded><![CDATA[<h2>Strings</h2>
<p>Strings are surrounded in quotes. For example, <code>"David"</code> is a string.</p>
<p><a href="http://ruby-doc.org/core/classes/String.html">A complete list of Ruby string methods is here.</a></p>
<p><strong>.reverse</strong><br />
<code>"David".reverse<br />
>> "divaD"</code></p>
<p><strong>.length</strong><br />
<code>"David".length<br />
>> 5</code></p>
<p><strong>.strip</strong><br />
Removes white space around a string.<br />
<code>"David  ".strip<br />
>> "David"</code></p>
<p><strong>multiplication</strong><br />
<code>"David" * 5<br />
>> "DavidDavidDavidDavidDavid"</code></p>
<h2>Converting Object Types</h2>
<p><code><strong>.to_s</strong></code> &#8211; converts to strings<br />
<code><strong>.to_i</strong></code> &#8211; converts to integers<br />
<code><strong>.to_a</strong></code> &#8211; converts to arrays</p>
<h2>Arrays / Lists</h2>
<p>Use brackets [].<br />
<code>[12, 47, 35]</code></p>
<p><code><strong>.max</strong></code><br />
<code>[12, 47, 35].max<br />
>> 47</code></p>
<h2>Hash / Dictionary / Associative Array</h2>
<p>A hash is when you want to associate one thing with something else, like a dictionary. These are called Key, Value pairs.<br />
Hashes use curly braces <code>{}</code>.<br />
<code><br />
food["Fish"] = :yum<br />
food["Dog"] = :yuck<br />
food["Beef"] = :delicious</p>
<p>food<br />
>> {"Fish" => :yum, "Dog" => :yuck, "Beef" => :delicious}<br />
rating<br />
food.keys<br />
>> ["Fish", "Dog", "Beef"]<br />
</code></p>
<h2>Blocks</h2>
<p>Using the above example of food, you may use a block like the following to tally your results.</p>
<p><code>books.values.each { |rate| ratings[rate] += 1 }<br />
>> [:yum, :delicious, :yuck]</p>
<p>ratings<br />
>> {:yum => 1, :yuck => 1, :delicious => 1}<br />
</code></p>
<p>Another example of using a block:<br />
<code>5.times {print "Yes!"}<br />
>> Yes!Yes!Yes!Yes!Yes!</code></p>
<h2>Classes</h2>
<p>String, Array, Hash are all examples of Classes.</p>
<p><strong>Creating a class</strong><br />
<code>class BlogEntry<br />
  attr_accessor :title, :time, :fulltext, :mood<br />
end</code></p>
<p><code>attr_accessor</code> is how you define variables, or in this case attributes attached to a class.</p>
<p>Let&#8217;s start a new entry.<br />
<code>entry = BlogEntry.new<br />
entry.title = "Hello world!"<br />
entry.fulltext = "Yes this is my first post!"<br />
entry.mood = :sick<br />
entry.time = Time.now<br />
</code></p>
<p><strong>The <code>initalize</code> Method</strong><br />
Using the initalize method you won&#8217;t have to type the time every post.</p>
<p><code>class BlogEntry<br />
  def initalize( title, mood, fulltext )<br />
    @time = Time.now<br />
    @title, @mood, @fulltext = title, mood, fulltext<br />
  end<br />
end</code></p>
<p><strong>Important things to notice</strong><br />
Outside the class we use accessors: <code>entry.time = Time.now</code>. But inside we use instance variables: <code>@time = Time.now</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/03/learning-ruby-and-rails-notes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performing Auto-Complete using Ruby on Rails 2.x</title>
		<link>http://www.bloggeh.com/2009/03/15/performing-auto-complete-using-ruby-on-rails-2x/</link>
		<comments>http://www.bloggeh.com/2009/03/15/performing-auto-complete-using-ruby-on-rails-2x/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 06:58:19 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[auto complete]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=83</guid>
		<description><![CDATA[http://share-facts.blogspot.com/2009/02/autocompleter-example-in-ruby-on-rails.html
]]></description>
			<content:encoded><![CDATA[<p><a href="http://share-facts.blogspot.com/2009/02/autocompleter-example-in-ruby-on-rails.html">http://share-facts.blogspot.com/2009/02/autocompleter-example-in-ruby-on-rails.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2009/03/15/performing-auto-complete-using-ruby-on-rails-2x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

