<?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</title>
	<atom:link href="http://www.bloggeh.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bloggeh.com</link>
	<description>Bits and pieces</description>
	<lastBuildDate>Sun, 01 Aug 2010 13:13:03 +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>Basecamp notes from DHH</title>
		<link>http://www.bloggeh.com/2010/08/01/basecamp-notes-from-dhh/</link>
		<comments>http://www.bloggeh.com/2010/08/01/basecamp-notes-from-dhh/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 13:13:03 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/2010/08/01/basecamp-notes-from-dhh/</guid>
		<description><![CDATA[1.
First focus on your writing. Simplicity.
Have good human writing. Nobodies impressed by big words.
2. Planning 5 years out is guessing
wastes your time and sucks your energy.
3.
Decisions are temporary.
What matters most is starting.
Just do something.
4. Have constraints! Set them yourself!
Forces you to make decisions and get things done.
Not waste time.
A sense of urgency.
Spending and earning your [...]]]></description>
			<content:encoded><![CDATA[<p>1.<br />
First focus on your writing. Simplicity.<br />
Have good human writing. Nobodies impressed by big words.</p>
<p>2. Planning 5 years out is guessing<br />
wastes your time and sucks your energy.</p>
<p>3.<br />
Decisions are temporary.<br />
What matters most is starting.<br />
Just do something.</p>
<p>4. Have constraints! Set them yourself!<br />
Forces you to make decisions and get things done.<br />
Not waste time.<br />
A sense of urgency.</p>
<p>Spending and earning your own money is a powerful driving force!</p>
<p>5.<br />
10 hours per week, 6 months.</p>
<p>6.<br />
It doesn&#8217;t work to go head to head with someone who has more than you!<br />
So you have to do something different.<br />
Fewer features. Under-do your competition.</p>
<p>7.<br />
No overnight successes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/08/01/basecamp-notes-from-dhh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with Models</title>
		<link>http://www.bloggeh.com/2010/05/23/working-with-models/</link>
		<comments>http://www.bloggeh.com/2010/05/23/working-with-models/#comments</comments>
		<pubDate>Sun, 23 May 2010 13:12:10 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=239</guid>
		<description><![CDATA[Models
In Rails, the default data structure for a data model is called, naturally enough, a model (the M in MVC) . The default Rails solution to the problem of persistence is to use a database for long-term data storage, and the default library for interacting with the database is called Active Record.1
Active Record comes with [...]]]></description>
			<content:encoded><![CDATA[<h1>Models</h1>
<p>In Rails, the default data structure for a data model is called, naturally enough, a model (the M in MVC) . The default Rails solution to the problem of persistence is to use a database for long-term data storage, and the default library for interacting with the database is called Active Record.1<br />
Active Record comes with a host of methods for creating, saving, and finding data objects, all without having to use the structured query language (SQL) used by relational databases. Moreover, Rails has a feature called migrations to allow data definitions to be written in pure Ruby, without having to learn an SQL data definition language (DDL). The effect is that Rails insulates you almost entirely from the details of the data store.</p>
<h1>Create the model</h1>
<pre class="css">$ script/generate rspec_model User name:string email:string</pre>
<p>Migrate &#8220;up&#8221; using</p>
<pre class="css">$ rake db:migrate</pre>
<p>Roll back (down) using</p>
<pre class="css">$ rake db:rollback</pre>
<h1>Model annotation</h1>
<p>Though it’s not strictly necessary, I like to annotate my Rails models using the annotate models plugin:</p>
<pre class="css">$ script/plugin install \
&gt; http://repo.pragprog.com/svn/Public/plugins/annotate_models
$ rake annotate_models</pre>
<p>This will cause your model files to look like the following:</p>
<pre class="ror"># == Schema Information
# Schema version:
# Table name:
# id :integer  not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime
# updated_at :datetime
#

class User &lt; ActiveRecord::Base
end</pre>
<p>After adding any plugins, remember to commit to Git</p>
<pre class="css">$ git add .
$ git commit -am "Annotated models"</pre>
<p>Accessible attributes<br />
Another step that isn’t strictly necessary but is a really good idea is to tell Rails which attributes of the model are accessible, i.e., which attributes can be modified by outside users (such as users submitting requests with web browsers). We do this with the attr accessible method. Using attr accessible is important for preventing a mass assignment vulnerability, a distressingly common and often serious security hole in many Rails applications.</p>
<pre class="ror">class User &lt; ActiveRecord::Base
  attr_accessible :name, :email
end</pre>
<h1>Searching models</h1>
<pre class="ror">User.find(1)  # where 1 is the User ID
User.find_by_email("david@example.com")  # notice the method being called to search for the email.
User.first  # finds the first User
User.all  # finds all Users and returns them in an array</pre>
<h1>Two ways to update attributes</h1>
<pre class="ror">user.email = "notDavid@example.com"
user.save</pre>
<p>or using <code>update_attributes</code> which performs the update and saves in one step. It returns true if the save was successful.</p>
<pre class="ror">user.update_attributes(:name =&gt; "The Guy", :email =&gt; "guy@example.com")
&gt;&gt; true</pre>
<h1>Model validations</h1>
<p>Add validations to your model files.</p>
<pre class="ruby">class User &lt; ActiveRecord::Base
  attr_accessible :name, :email

  validates_presence_of :name
end</pre>
<p>The database will now not allow save&#8217;s to pass if all validations do not pass. Use the <code>valid?</code> method to check if an object passes all validations.</p>
<p>Don&#8217;t forget to use table indexes when searching using a database column or ensuring uniqueness.<br />
<code>$ script/generate migration add_email_uniqueness_index</code><br />
<code>add_index :user, :email, :unique =&gt; true</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/23/working-with-models/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Tutorial Notes</title>
		<link>http://www.bloggeh.com/2010/05/23/rails-tutorial-notes-2/</link>
		<comments>http://www.bloggeh.com/2010/05/23/rails-tutorial-notes-2/#comments</comments>
		<pubDate>Sun, 23 May 2010 11:27:50 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=229</guid>
		<description><![CDATA[Using Test Driven Development, create your controller using

$ script/generate rspec_controller Users new

Remember to remove the view_specs because we don&#8217;t use them.

$ rm -rf spec/views

Don&#8217;t forget to integrate views into our Controller spec test so we can test for things like the correct title in our views.

describe UsersController do
  integrate_views
  do ...
   [...]]]></description>
			<content:encoded><![CDATA[<p>Using Test Driven Development, create your controller using</p>
<pre name="code" class="css">
$ script/generate rspec_controller Users new
</pre>
<p>Remember to remove the view_specs because we don&#8217;t use them.</p>
<pre name="code" class="css">
$ rm -rf spec/views
</pre>
<p>Don&#8217;t forget to integrate views into our Controller spec test so we can test for things like the correct title in our views.</p>
<pre name="code" class="ror">
describe UsersController do
  integrate_views
  do ...
    ...
    ...
  end
end
</pre>
<p>Make sure your tests pass, then commit to git (and push if required)</p>
<pre name="code" class="css">
$ spec spec/
$ git add .
$ git commit -am "Finished layout and routes"
$ git checkout master
$ git merge filling-in-layout
$ git push
</pre>
<h1>Adding debug</h1>
<pre name="code" class="ror">
debug(params) if Rails.env.development?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/23/rails-tutorial-notes-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails relevant Ruby</title>
		<link>http://www.bloggeh.com/2010/05/18/rails-relevant-ruby/</link>
		<comments>http://www.bloggeh.com/2010/05/18/rails-relevant-ruby/#comments</comments>
		<pubDate>Mon, 17 May 2010 14:06:37 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=225</guid>
		<description><![CDATA[
stylesheet_link_tag 'blueprint/screen', :media => 'screen'

Blocks can be more than one line, and often are. In Rails Tutorial we’ll follow the common convention of using curly braces only for short one-line blocks and the do..end syntax for longer one-liners and for multi-line blocks.
To inspect an object use the object.inspect method. or p object for short.
]]></description>
			<content:encoded><![CDATA[<pre name="code" class="ror">
stylesheet_link_tag 'blueprint/screen', :media => 'screen'
</pre>
<p>Blocks can be more than one line, and often are. In Rails Tutorial we’ll follow the common convention of using curly braces only for short one-line blocks and the do..end syntax for longer one-liners and for multi-line blocks.</p>
<p>To inspect an object use the object.inspect method. or <code>p object</code> for short.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/18/rails-relevant-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Test Driven Development (TDD)</title>
		<link>http://www.bloggeh.com/2010/05/16/test-driven-development-tdd/</link>
		<comments>http://www.bloggeh.com/2010/05/16/test-driven-development-tdd/#comments</comments>
		<pubDate>Sun, 16 May 2010 13:00:03 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[spec]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test driven development]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/?p=215</guid>
		<description><![CDATA[When testing Rails applications the favoured test suite is Rspec.
For Ruby versions 1.8.7 and under, the below instructions should get you going.

$ [sudo] gem install rspec -v 1.3.0
$ [sudo] gem install rspec-rails -v 1.3.2

The test folder is now named spec. You no longer need your test folder.
To setup rspec tests for a controller named Pages:
$ [...]]]></description>
			<content:encoded><![CDATA[<p>When testing Rails applications the favoured test suite is <a href="http://www.rspec.info">Rspec</a>.</p>
<p>For Ruby versions 1.8.7 and under, the below instructions should get you going.<br />
<code><br />
$ [sudo] gem install rspec -v 1.3.0<br />
$ [sudo] gem install rspec-rails -v 1.3.2<br />
</code></p>
<p>The test folder is now named <b>spec</b>. You no longer need your <code>test</code> folder.</p>
<p>To setup rspec tests for a controller named <code>Pages</code>:<br />
<code>$ script/generate rspec_controller Pages home contact</code></p>
<p>Your test file <code>pages_controller_spec.rb</code> will contain a test looking like the following:<br />
<code><br />
  describe "GET 'home'" do<br />
    it "should be successful" do<br />
      get 'home'<br />
      response.should be_success<br />
    end<br />
  end<br />
</code><br />
The first line is a description. The second line is also and neither have any effect on the test. The third line performs a GET request to the page. The fourth line describes the desired result. <code>should_be_success</code> looks for status code 200.</p>
<p>To run your tests:<br />
<code>$ spec spec/</code></p>
<h2>Red, Green, Refactor</h2>
<p>This is the process you work through when following Test Driven Development. First get the test to fail, then to pass, then refactor your code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/05/16/test-driven-development-tdd/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>Tim Ferriss &#8211; How to prepare for Public Speaking</title>
		<link>http://www.bloggeh.com/2010/04/12/tim-ferriss-how-to-prepare-for-public-speaking/</link>
		<comments>http://www.bloggeh.com/2010/04/12/tim-ferriss-how-to-prepare-for-public-speaking/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 23:32:35 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[public speaking]]></category>
		<category><![CDATA[tim ferriss]]></category>

		<guid isPermaLink="false">http://www.bloggeh.com/2010/04/12/tim-ferriss-how-to-prepare-for-public-speaking/</guid>
		<description><![CDATA[http://www.fourhourworkweek.com/blog/2010/04/11/public-speaking-how-i-prepare-every-time/
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fourhourworkweek.com/blog/2010/04/11/public-speaking-how-i-prepare-every-time/">http://www.fourhourworkweek.com/blog/2010/04/11/public-speaking-how-i-prepare-every-time/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bloggeh.com/2010/04/12/tim-ferriss-how-to-prepare-for-public-speaking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
