<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>All About Ruby</title>
	<atom:link href="http://allaboutruby.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://allaboutruby.wordpress.com</link>
	<description>Ruby newbie view on the web development using Ruby on Rails</description>
	<pubDate>Sat, 26 Aug 2006 20:18:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language></language>
			<item>
		<title>Building a user authorization system in PHP - Part II</title>
		<link>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-ii/</link>
		<comments>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-ii/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 20:18:34 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-ii/</guid>
		<description><![CDATA[Hashing passwords
In the last walkthrough you should have created a script that allows user to enter information in the HTML form and then stores this information in the database. The most obvious security hole is that we store password in the database in plain text. If somebody will be able to get the contents of your database, [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Hashing passwords</strong></p>
<p>In the last walkthrough you should have created a script that allows user to enter information in the HTML form and then stores this information in the database. The most obvious security hole is that we store password in the database in plain text. If somebody will be able to get the contents of your database, all user passwords will be in plain view to see.</p>
<p>This part of tutorial helps you learn how to make the passwords more secure. The common practice for storing passwords is storing a hash of a password, which is a scrambled copy of it. There is no easy way to decrypt the password, so this set up is much more secure. You will then compare the hash stored in MySQL with the hash of the user-input password. If both hashes are identical, then the password is correct.</p>
<p>There are 2 basic algorythms: <strong>SHA1</strong> and <strong>MD5</strong>. Because a specific password always corresponds to a specific hash value, the attacker does not need to brute-force the hash to get the underlying password. If you build a database of all possible passwords, you can get the plain-text password by doing a hash lookup in the database. Here is an example: <a target="_blank" href="http://md5.rednoize.com/" title="MD5 lookup">MD5 lookup</a>. As there are no reliable SHA1 lookup services at the moment, it is safer to use this algorythm with some kind of modification (called <a target="_blank" href="http://en.wikipedia.org/wiki/Salt_(cryptography)" title="salt">salt</a>). Here&#8217;s the line you need to add to your register.php:</p>
<p><strong>$password = sha1(sha1($password).&#8221;mysecretcode&#8221;);</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=44&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-ii/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building a user authorization system in PHP - part I</title>
		<link>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-i/</link>
		<comments>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-i/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 19:54:18 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-i/</guid>
		<description><![CDATA[Recently I needed to start my new PHP project and required a basic (but secure) user authorization / registration script. To my surprise I was not able to find one script that would allow me to register users in MySQL database, require user activation via email, show a turing (aka captcha) at the login form [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recently I needed to start my new PHP project and required a basic (but secure) user authorization / registration script. To my surprise I was not able to find one script that would allow me to register users in MySQL database, require user activation via email, show a turing (aka captcha) at the login form and have no obvious security holes.</p>
<p>16 hours later, I now have my own script and understand better why there is no universal script available on the Net (the task turns out non-trivial and requires a lot of security tweaking).</p>
<p>In this post I will start discussing how a user authorization script should be developed. <span id="more-43"></span>You will be interested in this script if you:</p>
<p>1. Create projects in PHP<br />
2. Require some basic user registration and login<br />
3. Do not want your site to be easily hackable</p>
<p>Ok, here goes&#8230;</p>
<p>Any basic user auth script will consist of the following:</p>
<p>1. Registration HTML form<br />
2. Registration validation<br />
3. Creating a user record in MySQL<br />
4. Login HTML form<br />
5. Login validation<br />
6. Session creation and management<br />
7. Session destruction on logout</p>
<p>Apart from these it is also always nice to have the following:</p>
<p>1. Use a captcha to prevent automatic registrations<br />
2. Store a list of crack attempts and ban users<br />
3. Encrypt password<br />
4. Send activation emails<br />
5. Prevent MySQL “insertion bug” attacks<br />
6. Prevent session hijacking</p>
<p><strong>1. Creating an HTML registration form </strong></p>
<p>So, let’s start with the easy part: the HTML form. Here it is. Copy &amp; save it to a file called form.php (there is no php at the moment, only pure HTML but you might need it later).</p>
<p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
</code><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&gt;<br />
&lt;title&gt;Registration form&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;form id=&#8221;registrationform&#8221; name=&#8221;registrationform&#8221; method=&#8221;post&#8221; action=&#8221;register.php&#8221;&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;regform&#8221; value=&#8221;regform&#8221; /&gt;<br />
&lt;label&gt;Username: &lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; maxlength=&#8221;15&#8243;/&gt; &lt;/label&gt;<br />
&lt;label&gt;&lt;br /&gt; Email: &lt;input type=&#8221;text&#8221; name=&#8221;email&#8221; maxlength=&#8221;40&#8243;/&gt; &lt;/label&gt;<br />
&lt;label&gt;&lt;br /&gt; Password: &lt;input type=&#8221;password&#8221; name=&#8221;password&#8221; maxlength=&#8221;20&#8243;/&gt; &lt;/label&gt;<br />
&lt;label&gt;&lt;br /&gt; Verify password: &lt;input name=&#8221;password2&#8243; type=&#8221;password&#8221; maxlength=&#8221;20&#8243;/&gt; &lt;/label&gt;<br />
&lt;br/&gt; &lt;input name=&#8221;submit&#8221; value=&#8221;submit&#8221; type=&#8221;submit&#8221; /&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt; </code></p>
<p><code></code>Here are some comments: This is how the HTML FORM is set up:</p>
<p><strong>&lt;form id=&#8221;registrationform&#8221; name=&#8221;registrationform&#8221; method=&#8221;post&#8221; action=&#8221;register.php&#8221;&gt;</strong></p>
<p>Method should always be POST, which is a tiny bit more secure. The script name in action attribute is “<strong>register.php</strong>”, we will call this script once the user hits “Submit” button.</p>
<p>After that follows the standard input forms for your registration form. Spend some time thinking what information you will require on your site users.</p>
<p><strong>&lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; maxlength=&#8221;15&#8243;/&gt;</strong></p>
<p>The only things to note here is that the name attribute should be unique (you will need it later) and every field should have a maxlength, so that user will not be allowed to enter a 250-letter long username.</p>
<p>Finally, this code actually displays a button and submits the form to our script “register.php” if you click on it or hit “Enter”:</p>
<p><strong>&lt;input name=&#8221;submit&#8221; value=&#8221;submit&#8221; type=&#8221;submit&#8221; /&gt; </strong></p>
<p><strong>2. Creating a MySQL table to hold users</strong></p>
<p>Ok, now you need somewhere to store all this info. You should already have a MySQL database ready (you should know username, database name, database password and database address). The usual set-up for hosting providers is to give you a username = database name = your login at hosters and database address is most of the time “localhost”.</p>
<p>You should also have some way to administer the MySQL. Usually it’s phpMyadmin. Go there, select the database and click SQL. Paste the following code in the dialog and execute it (but before doing that, better read what it means below!)</p>
<p><strong>CREATE TABLE `users` (<br />
`id` int(11) NOT NULL auto_increment,<br />
`username` varchar(15) NOT NULL default &#8221;,<br />
`password` varchar(100) NOT NULL default &#8221;,<br />
`ip` varchar(20) NOT NULL default &#8221;,<br />
`email` varchar(50) NOT NULL default &#8221;,<br />
`status` int(3) NOT NULL default &#8216;0&#8242;,<br />
`added` timestamp NOT NULL default &#8216;0000-00-00 00:00:00&#8242;,<br />
PRIMARY KEY (`id`) )<br />
ENGINE=MyISAM DEFAULT CHARSET= latin1 AUTO_INCREMENT;</strong></p>
<p>SQL actually has a very simple syntax. We are creating a table “<strong>users</strong>” which has 7 fields. <strong>id</strong> is the id of the record, every record should have one, and it should be unique. You let MySQL select the <strong>id</strong> for you by specifying “auto_increment”. There are 3 most useful data types (at least for the registration form) in MySQL: <strong>INT</strong>, <strong>VARCHAR</strong> and <strong>TIMESTAMP</strong>.</p>
<p>You use INT to store integers, you use VARCHAR to store strings and you use TIMESTAMP to store date and time. We should also specify length for INT and VAR in round brackets. If you need to add more fields to the table, it can easily be done using phpMyadmin (see its documentation).</p>
<p>Once the table is created, it is time to create our register.php script, that will receive the values from the application form.</p>
<p><strong>3. Creating the register.php script</strong></p>
<p>First, define those variables, filling in the appropriate info:</p>
<p><strong>$db_host=&#8221;localhost&#8221;;<br />
$db=&#8221;yourinfohere&#8221;;<br />
$db_user=&#8221;yourinfohere&#8221;;<br />
$db_passwd=&#8221;yourpasswordhere&#8221;;</strong></p>
<p>Then, create the procedure to connect to the database:</p>
<p><strong>function db_connect() {<br />
Global $db, $db_base, $db_user, $db_passwd;<br />
$connect=@mysql_connect($db_host,$db_user,$db_passwd);<br />
if(!$connect) return $connect;<br />
$connect=@mysql_select_db($db);<br />
return $connect; }</strong></p>
<p>Now, call the function and it should connect to the database. You can test it by writing something like:</p>
<p><strong>If (!db_connect()) { echo “Error connecting!”; } </strong></p>
<p>Ok, to make you happy, let’s create a user based on the info you sent in the HTML form. Here is the code you will use:</p>
<p><strong>$ip = $REMOTE_ADDR; // this will get user’s IP address<br />
$username = $_POST[“username”];<br />
$password = $_POST[“password”];<br />
$email = $_POST[“email”];<br />
$query = &#8220;insert into users set<br />
ip=&#8217;$ip&#8217;,<br />
username=&#8217;$username&#8217;,<br />
password=&#8217;$password&#8217;,<br />
egold=&#8217;$egold&#8217;,<br />
email=&#8217;$email&#8217;,<br />
added=now(),<br />
status=&#8217;0&#8242;;&#8221;;</strong><strong>$res=@mysql_query($query);</p>
<p></strong>Some explanations here: the fields enters into the application form are being passed in the <strong>$_POST</strong> array to your script. The identifier of the array item is the name of the INPUT tag.</p>
<p>So, if you want to extend your registration form to include an address, for example, you will need to add the following:</p>
<p>To your form.php:</p>
<p><strong>&lt;label&gt;&lt;br /&gt; Address: &lt;input type=&#8221;text&#8221; name=&#8221;address&#8221; maxlength=&#8221;60&#8243;/&gt; &lt;/label&gt;</strong></p>
<p>To your database creation script:</p>
<p><strong>`address` varchar(60) NOT NULL default &#8221;,</strong></p>
<p>To your register.php:</p>
<p><strong>$address = $_POST[“address”];</strong></p>
<p>And finally you need to modify the SQL query to look like this:</p>
<p>$query = &#8220;insert into users set ip=&#8217;$ip&#8217;,<br />
username=&#8217;$username&#8217;,<br />
address=&#8217;$address&#8217;,<br />
password=&#8217;$password&#8217;,<br />
egold=&#8217;$egold&#8217;,<br />
email=&#8217;$email&#8217;,<br />
added=now(),<br />
status=&#8217;0&#8242;;&#8221;;</p>
<p>Hopefully, you will find it simple. It really is <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>4. How it all gels together</strong></p>
<p>Now, let’s see how it works. You should have a MySQL table “<strong>users</strong>” and two files – <strong>form.php</strong> and <strong>register.php</strong>. Upload it to your hoster and run the form.php file. Fill it out and click “Submit”. Now, the register.php file should be loaded in your browser and it will show an empty page.</p>
<p>However, if you go and take a look at your MySQL table “users”, a new record will be created there with the details you provided. This is basic stuff, but you are on the right track.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=43&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/08/26/building-a-user-authorization-system-in-php-part-i/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby Blocks 101</title>
		<link>http://allaboutruby.wordpress.com/2006/01/20/ruby-blocks-101/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/20/ruby-blocks-101/#comments</comments>
		<pubDate>Fri, 20 Jan 2006 01:00:33 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/20/ruby-blocks-101/</guid>
		<description><![CDATA[One of the difficulties you might have with jumping into Ruby on Rails is that you need to learn the Ruby language (yes, you do  ). And if you come from the PHP background as I am, the single weirdest thing in Ruby would be the notion of blocks. I have never seen the [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the difficulties you might have with jumping into Ruby on Rails is that you need to learn the Ruby language (yes, you do <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ). And if you come from the PHP background as I am, the single weirdest thing in Ruby would be the notion of <em>blocks. </em>I have never seen the blocks in any other language. The concept seems beautiful, but completely unrelated to anything I know about programming.</p>
<p>The concept of blocks is logical and intuitive, but most likely very different from the way you experienced programming. Blocks are like alien logic - something so basic, that it changes the meaning of everything. Think of how an amphibian race of super-intellectual beings would differ from humans - this is how different the blocks concept is from your PHP functions.</p>
<p>As blocks are the basic structures of Ruby, chances are you have already seen them and did not really understand what was going on. I hope this post will be able to help you out with getting the hang of the concept really quickly.</p>
<p>So let&#8217;s start with an easy example. Run irb (cmd irb.bat) and define the method:</p>
<p><strong>def aliens<br />
i = 1<br />
j = 2<br />
yield(i, j)<br />
end</strong></p>
<p>This method just assigns two variables and then passes those variables to the block. Now let&#8217;s call the block:</p>
<p><strong>aliens { |x, y| puts x, y }</strong></p>
<p>It works as follows: <strong>aliens </strong>method is called, with Ruby recognizing that this method has a block attached to it. Once the <strong>yield</strong> is encountered within the <strong>aliens, </strong>it is passed to the block together with any parameters in the brackets. As <strong>i</strong> and <strong>j</strong> are local variables, we need to define the first and second variable to be used to hold <strong>i</strong> and <strong>j</strong> values. Finally we have the Ruby code that does something with those parameters. <strong>Puts</strong> just displays the values of <strong>i</strong> and <strong>j</strong> on screen. But you can do something more complicated:</p>
<p><strong>aliens { |x, y| puts x+y*y }</strong></p>
<p>This should display 5.</p>
<p>If you are not confused at this moment, great - you have almost mastered the blocks ;). If you are, think about the <strong>aliens </strong>as a function that allows three parameters - x, y and some arbitrarily complex Ruby code. Yield is the place where this code is executed. To make sure that this is the case, try this: (copy the code, save it to blocks.rb in your project directory and run <strong>ruby blocks.rb</strong>)</p>
<p><strong>def aliens<br />
i = 1<br />
j = 2<br />
yield(i, j)<br />
i = &#8220;magick&#8221;<br />
return nil<br />
end</strong></p>
<p><strong>aliens { |x, y| puts x }</strong></p>
<p>The script should print &#8220;1&#8243;. This is easy stuff. (Pedantic note. You can ignore &#8220;<strong>return nil</strong>&#8220;, it is there because Ruby returns the last value in the function (=method) as the result of the function, so if you run the code above in irb without &#8220;return nil&#8221;, you will see that aliens actually returns &#8220;magick&#8221;)</p>
<p>Another cool feature is the ability to test whether the method has a block. Check out this code:</p>
<p><strong>def aliens<br />
if block_given?<br />
  i = 1<br />
  j = 2<br />
  yield(i, j)<br />
 else puts &#8220;magick&#8221;<br />
 end<br />
end</strong></p>
<p><strong>aliens { |x, y| puts x }<br />
aliens</strong></p>
<p>In that case if the block is provided to the method, we execute the <strong>if </strong>statement, otherwise we execute the else statement. So, as a result the script should print &#8220;1&#8243; and &#8220;magick&#8221;.</p>
<p>How cool is that? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=42&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/20/ruby-blocks-101/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Another good introduction article from Curt Hibbs</title>
		<link>http://allaboutruby.wordpress.com/2006/01/16/another-good-introduction-article-from-curt-hibbs/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/16/another-good-introduction-article-from-curt-hibbs/#comments</comments>
		<pubDate>Mon, 16 Jan 2006 19:51:03 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/16/another-good-introduction-article-from-curt-hibbs/</guid>
		<description><![CDATA[Curt Hibbs&#8217; tutorials are the only accessible tutorials that I&#8217;ve read on Ruby on Rails. Curt has also written a great introductory article on Rails which you can find here.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Curt Hibbs&#8217; tutorials are the only accessible tutorials that I&#8217;ve read on Ruby on Rails. Curt has also written a great introductory article on Rails which you can find <a href="http://www.onlamp.com/pub/a/onlamp/2005/10/13/what_is_rails.html" target="_blank">here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=41&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/16/another-good-introduction-article-from-curt-hibbs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Newbies beware!</title>
		<link>http://allaboutruby.wordpress.com/2006/01/16/newbies-beware/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/16/newbies-beware/#comments</comments>
		<pubDate>Mon, 16 Jan 2006 19:48:32 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/16/newbies-beware/</guid>
		<description><![CDATA[So, I am trying to get deeper in the understanding of Ruby and Rails and things are progressing nicely. However, I have to say - the information on Rails and Ruby is not up to notch. Unless you are a seasoned programmer or a smart hacker, chances are you will be lost when trying to [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So, I am trying to get deeper in the understanding of Ruby and Rails and things are progressing nicely. However, I have to say - the information on Rails and Ruby is not up to notch. Unless you are a seasoned programmer or a smart hacker, chances are you will be lost when trying to understand how to use the Rails API or what exactly you are supposed to do after you have installed Ruby on Rails and did an ONLamp tutorial. A good sentiment that every newbie will recognize instantly is expressed <a href="http://sean.dutchnation.com/?p=10" target="_blank">here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=40&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/16/newbies-beware/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TextMate v1.5 released</title>
		<link>http://allaboutruby.wordpress.com/2006/01/10/textmate-v15-released/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/10/textmate-v15-released/#comments</comments>
		<pubDate>Tue, 10 Jan 2006 21:13:07 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/10/textmate-v15-released/</guid>
		<description><![CDATA[TextMate by the look of it is a great editor for Ruby developers. New version was released just recently, but there are still no plans to release a PC version - only Mac users need to celebrate.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>TextMate by the look of it is a great editor for Ruby developers. <a href="http://macromates.com/blog/archives/2006/01/06/textmate-15/" target="_blank">New version</a> was released just recently, but there are still no plans to release a PC version - only Mac users need to celebrate.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=38&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/10/textmate-v15-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby on Rails Cheatsheet</title>
		<link>http://allaboutruby.wordpress.com/2006/01/10/ruby-on-rails-cheatsheet/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/10/ruby-on-rails-cheatsheet/#comments</comments>
		<pubDate>Tue, 10 Jan 2006 21:01:00 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/10/ruby-on-rails-cheatsheet/</guid>
		<description><![CDATA[Blaine Kendall released a very nice 14-page PDF that summarizes nicely gotchas, syntax and some basic building blocks of both Ruby and Rails. Get the pdf from his blog post here.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Blaine Kendall released a very nice 14-page PDF that summarizes nicely gotchas, syntax and some basic building blocks of both Ruby and Rails. Get the pdf from his <a href="http://www.blainekendall.com/index.php/rubyonrailscheatsheet/" target="_blank">blog post here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=37&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/10/ruby-on-rails-cheatsheet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing Rails on Windows (step-by-step tutorial)</title>
		<link>http://allaboutruby.wordpress.com/2006/01/09/installing-rails-on-windows-step-by-step-tutorial/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/09/installing-rails-on-windows-step-by-step-tutorial/#comments</comments>
		<pubDate>Mon, 09 Jan 2006 21:33:34 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/09/installing-rails-on-windows-step-by-step-tutorial/</guid>
		<description><![CDATA[Ok, so this will basically be somewhat a repeat of the information made by Curt Hibbs in this great hands-on tutorial. However, the versions of all products changed from the time Curt made his tutorial, and in some areas I felt that additional description was required. So, in this tutorial you&#8217;ll get a step-by-step instructions [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ok, so this will basically be somewhat a repeat of the information made by Curt Hibbs in <a href="http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html">this great hands-on tutorial</a>. However, the versions of all products changed from the time Curt made his tutorial, and in some areas I felt that additional description was required. So, in this tutorial you&#8217;ll get a step-by-step instructions on installing Rails on Windows 2000 Server (Windows XP would be very similar).</p>
<p><span id="more-16"></span></p>
<p>In order to have a fully working development environment, you can use your PC. You will need to install:</p>
<ul>
<li>Ruby - the language</li>
<li>Ruby Gems - the plug-in manager for Ruby</li>
<li>Scite or FreeRIDE - IDE for Ruby</li>
<li>MySQL - the database</li>
<li>MySQL query builder / MySQL admin tools - GUI to create databases, add users and create tables</li>
<li>Rails Framework</li>
</ul>
<p><strong>I. Installing Ruby<br />
</strong>This is easy. Just get the latest <a href="http://rubyinstaller.rubyforge.org/wiki/wiki.pl">One-click Installer for Windows</a> (currently 1.8.2-15). Installation is simple, and indeed one-click. Once the installation is complete, check that path to ruby\bin directory is in your PATH variable (Run &#8220;cmd&#8221;, then type &#8220;path&#8221; at the prompt and check that the path is there.</p>
<p>The great thing about the one-click installer is that it comes with Ruby Gems, Scite and FreeRIDE preinstalled. The thing to watch out for is that one-click installer does not have the very latest version of Ruby, so when you are reading Ruby Docs, make sure you know which version of Ruby you have (run &#8220;ruby -v&#8221; in the command prompt).</p>
<p><strong>II. Installing MySQL<br />
</strong>This might be more tricky, depending on your home computer&#8217;s set up. First, download and run the latest Windows Essentials (x86) version of MySQL (currently 5.0.18). After the files are unzipped, an Instance Config should run automatically (you can run it manually at any time from your MySQL bin directory just run &#8220;MySQLInstanceConfig.exe&#8221;).</p>
<p>Below are the options to use for the Instance Configuration.</p>
<p>1. Select &#8220;Detailed Configuration&#8221;</p>
<p><img alt="p1.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p1.jpg" /></p>
<p>2. Choose &#8220;Developer Machine&#8221;</p>
<p><img alt="p2.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p2.jpg" /></p>
<p>3. Choose &#8220;Multifunctional Database&#8221;</p>
<p><img alt="p3.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p3.jpg" /></p>
<p>4. Leave the next screen unchanged</p>
<p><img alt="p4.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p4.jpg" /></p>
<p>5. Choose &#8220;Decision Support / OLAP&#8221;</p>
<p><img alt="p5.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p5.jpg" /></p>
<p>6. From the security perspective it is better to have &#8220;Enable TCP/IP Networking&#8221; unchecked, however I wasn&#8217;t able to make MySQL work with Rails in that case. So, choose &#8220;Enable TCP/IP Networking&#8221; for now and leave &#8220;Strict mode&#8221; checked.</p>
<p><img alt="p61.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p61.jpg" /></p>
<p>7. Choose &#8220;Best Support for Multilingualism&#8221; (MySQL will use Unicode for stored data).</p>
<p><img alt="p7.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p7.jpg" /></p>
<p>8. Have both options checked.</p>
<p><img alt="p8.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p8.jpg" /></p>
<p>9. Now, create a password for root account. Make sure that you do not use an easily guessable password and do NOT leave these fields blank (ie, do not use blank password for root). Also, leave the &#8220;Enable root access from remote machines&#8221; unchecked.</p>
<p><img alt="p9.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p9.jpg" /></p>
<p>10. Click &#8220;Execute&#8221;. If everything went ok, you should have green tick marks for all installation steps.</p>
<p><img alt="p10.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p10.jpg" /></p>
<p>11. Now, you need to do some basic security tweaking, to make sure nobody hacks your database from the outside. Go to the MySQL directory (c:\mysql by default), open my.ini and add the following line to the [mysqld] section of your server configuration file:</p>
<p><strong>bind-address=127.0.0.1</strong></p>
<p>This line will make sure that only services from your localhost will be able to access database (so, this means you and your web server).</p>
<p>Now, you need to restart MySQL. Go to Services (In Windows 2000: Start -&gt; Programs -&gt; Accessories -&gt; Administrative tools -&gt; Services), find &#8220;MySQL&#8221;, highlight it, click &#8220;Stop&#8221; and then &#8220;Start&#8221; icon.</p>
<p>12. Quickly try if your mysql set up is working, by running this command in the prompt:</p>
<p><strong>mysql.exe -h 127.0.0.1 -u root -p</strong></p>
<p>You will be asked to type your password and if everything is fine, should be presented with the message &#8220;Welcome to the MySQL Monitor&#8221; and the mysql prompt. It works! You are almost there.</p>
<p>If it does not work - first, make sure that you are entering the password right (check Caps Lock and Language Indicator). Check that MySQL service is running (see step 11). Another usual suspect is your local Firewall (your router firewall will not interfere with the local MySQL installation). A quick fix would be to allow communication for ru<strong>by.exe</strong> and <strong>mysqld-nt.exe</strong> on all ports (check your Firewall manual or help).</p>
<p><strong>III. Installing Rails</strong></p>
<p>1. Go into the ruby bin directory and run this command from the command prompt:</p>
<p><strong><code>gem install rails --include-dependencies</code></strong></p>
<p>(If this command gives you an error, you do not have the latest version of gems installed. Run &#8220;gem -v&#8221;, it should be 0.8.10. If it&#8217;s an earlier version, I recommend to reinstall the newest package - see beginning of the tutorial).</p>
<p>This command will install rails 1.0 and RDoc documentation for it. It should take up to 5-10 minutes, so do not worry when for a couple of minutes you just see a message &#8220;Updating Gem source index for: <a href="http://gems.rubyforge.org/">http://gems.rubyforge.org/</a>&#8221; - there is no progress bar or any other indication of activity, but it is doing the work.</p>
<p>At the end you should see something like this:</p>
<p><img alt="p11.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p11.jpg" /></p>
<p>2. After that, create a directory for all of your projects. I just have one in the ruby directory. Go into this directory by using the &#8220;cd c:\ruby/myprojectsdir&#8221; and run</p>
<p><strong>rails firstproject</strong></p>
<p>You should see something similar:</p>
<p><img alt="p12.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p12.jpg" /></p>
<p>3. Finally, &#8220;<strong>cd firstproject</strong>&#8221; and run</p>
<p><strong>ruby script/server</strong></p>
<p>This will run the file &#8220;server&#8221; (no extension) in the script subdirectory of &#8220;firstproject directory&#8221;, which will in turn run the Rails built-in web server WEBrick. Test the web server by opening the following address in your browser:</p>
<p><a href="http://127.0.0.1:3000/">http://127.0.0.1:3000/</a></p>
<p>You should see the following pic:</p>
<p><img alt="p131.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p131.jpg" /></p>
<p>One of the drawbacks of having a Ruby-based web server is that WEBrick needs to run in its separate command prompt window, so you should be careful not to close the window down incidentally, or you will need to restart the web server.</p>
<p><strong>Congratulations! YOU ARE ALMOST DONE! </strong></p>
<p><strong>IV. MySQL Admin</strong></p>
<p>Here, you have several options, however the tool I love the most - MySQL Control Center - is no longer in development. You can still download it <a href="http://sunsite.mff.cuni.cz/MIRRORS/ftp.mysql.com/downloads/mysqlcc.html">here</a> (v.0.9.2) or <a href="ftp://ftp.fi.muni.cz/pub/mysql/Downloads/MySQLCC/mysqlcc-0.9.4-win32.zip">here</a> (v.0.9.4). Or you can download <a href="http://dev.mysql.com/downloads/administrator/1.1.html">MySQL Administrator</a> and <a href="http://dev.mysql.com/downloads/query-browser/1.1.html">Query Browser</a> from MySQL.com. I haven&#8217;t tried those tools yet, so I will show how to work with MySQL CC, but the steps will be very similar.</p>
<p><strong>Note on MySQL CC and MySQL Administrator / Query Browser:<br />
</strong>MySQL CC is not fully compatible with MySQL 5.x, so it might be better to use Administrator and Query Browser. However, MySQL CC is a very easy to use bare-bones program and it allows to do everything you need in this tutorial. If you opt for Administrator / Query Browser set-up, you would use the Administrator only for creating database users (and in future for setting up security, back-ups and restarting MySQL). For all other things you will use the Query Browser (in the Query Browser databases are called &#8220;Schemas&#8221;, and when you first run QB, you can safely ignore the warning to supply the schema name).</p>
<p>1. Install MySQL Admin and run it.</p>
<p>2. Create a new database connection by clicking the icon shown (or press Ctrl-N):</p>
<p><img alt="p14.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p14.jpg" /></p>
<p>3. Fill out the information as shown in the picture below:</p>
<p><img alt="p15.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p15.jpg" /></p>
<p><strong>Name: </strong>This is any name you want - for GUI purposes only. Call it &#8220;My Development Database&#8221;.<br />
<strong>Host name: </strong>This would be either &#8220;localhost&#8221; or &#8220;127.0.0.1&#8243;. On some weird configs &#8220;localhost&#8221; might not work, so try to use either one.<br />
<strong>User name</strong>: &#8220;root&#8221;. Leave it as is.<br />
<strong>Password:</strong> your root password. Remember setting it when installing MySQL? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<strong>Make this server the default connection: </strong>If you do not have any other databases, tick this box. By running MySQL CC next time, you will automatically connect to the database.</p>
<p>Now, click the &#8220;Test&#8221; icon, and if successful, click &#8220;Add&#8221;.</p>
<p>4. Create the database.</p>
<p>Go to the main console. It now should have your database &#8220;My Development Database&#8221;. Check that it is connected, if not click the &#8220;Connect&#8221; icon.</p>
<p>Right click on the &#8220;Databases&#8221; folder and select &#8220;New database&#8221;. You will be presented with the following prompt. Just name the database &#8220;firstproject&#8221;, although it does not really matter how you call the database.</p>
<p><img alt="p16.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p16.jpg" /></p>
<p>5. Now, back to the main console window, you should see the database name &#8220;firstproject&#8221; in the list of databases for your server. Double click on the database and then click on the &#8220;Tables&#8221; subfolder. It should look something like this:</p>
<p><img alt="p17.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p17.jpg" /></p>
<p>6. Now, the database for your project has been created, you need to create a test table. Right click the &#8220;Tables&#8221; folder and choose &#8220;New table&#8221;. Let&#8217;s make two fields: id (type: int) and title (type: varchar).</p>
<p>&#8220;id&#8221; field is required by Rails and is the usual feature for the majority of tables. You do not usually insert the &#8220;id&#8221; directly, so we need to make sure that &#8220;id&#8221; is never empty (not null) and is automatically incremented (0,1,2,3,&#8230;). Also, make sure that the &#8220;id&#8221; is written in lowercase, for Rails to understand that this is your unique id field.</p>
<p><img alt="p18.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p18.jpg" /></p>
<p>Now, let&#8217;s define &#8220;id&#8221; as our primary field. Go into the &#8220;indexes&#8221; tab, select &#8220;id&#8221; field and press the right arrow, it should end up looking something like this:</p>
<p><img alt="p21.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p21.jpg" /></p>
<p>Now, add the &#8220;title&#8221; and choose the type &#8220;varchar&#8221;, like this (length of 100 symbols should be enough for your title, but when you will be adding a field for url you would want to change it to 255):</p>
<p><img alt="p19.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p19.jpg" /></p>
<p>Finally, click the &#8220;Save&#8221; icon and you will be asked to name your table. Rails has a special notation for naming tables - basically they have to be in plurals, as they will hold instances of particular class (objects).</p>
<p>Let&#8217;s call the table &#8220;Stories&#8221; (Rails is supposed to know the plural form for &#8220;Story&#8221;, so let&#8217;s try it out). Go back to the main console window and double click the &#8220;Tables&#8221; subfolder. On the right you will see the list of tables (we have only one at the moment - called &#8220;Stories&#8221;). Double click the table, it should return an empty set, as you do not have any records yet. (Do not try to create a record - MySQL CC will not correctly do this in MySQL 5.x).</p>
<p>7. Finally, it would be wrong to run your project using a root password. So, you need to create the database user especially for your project. It is very easy to do. In the main console right-click on the &#8220;User Administration&#8221; folder and select &#8220;New User&#8221;. Fill out the form as shown:</p>
<p><img alt="p22.jpg" src="http://allaboutruby.files.wordpress.com/2006/01/p22.jpg" /></p>
<p><strong>Username:</strong> rails (this would be the username exclusively used for your project)<br />
<strong>Host:</strong> localhost<br />
<strong>Password:</strong> password you will use to access this user account<br />
<strong>Priviliges:</strong> You should provide the least possible priviliges for the user. The ones selected by default are ok, but you can actually safely leave priviliges to only &#8220;Select, Insert, Update and Delete&#8221;, as we do not plan to create, drop (delete) or alter (change structure of) tables from our Rails scripts. Finally, select, to which databases you are allowing access. Select ONLY the &#8220;firstproject&#8221; database and click &#8220;Add&#8221;.</p>
<p><strong>V. Rails in action</strong></p>
<p>1. Now that the database model was prepared, we need to switch it on for our project. Go into your rails project subdirectory (you remember where you created it, right?). In the &#8220;config&#8221; subfolder you will find file <strong>database.yml</strong>. Open it and find the &#8220;development&#8221; section. In it, change database name to &#8220;firstproject&#8221;, username to &#8220;rails&#8221;, password to rails user password. Leave socket unchanged. Here is how it will look like:</p>
<p><strong>development:<br />
  adapter: mysql<br />
  database: firstproject <br />
  username: rails<br />
  password: railspass55<br />
  socket: /path/to/your/mysql.sock</strong></p>
<p>In order for those changes to work, you will need to restart the WEBrick server. Close the WEBrick window and run the server command again:</p>
<p><strong>ruby script/server</strong></p>
<p>2. You have the database schema defined and you configured Rails to access your database. Now, what we need is to create the class called &#8220;Story&#8221;. The easiest way to go is to create a scaffold, which is basically a default script to work with the standard database operations under the acronym of CRUD (Create Read Update Delete or in SQL terms: INSERT, SELECT, UPDATE and DELETE). To do this, again go to your script&#8217;s directory and run this command:</p>
<p><strong>ruby script\generate scaffold Story</strong></p>
<p>Make sure that you use the capital &#8220;S&#8221; - this is actually a Ruby rule that you need to follow - class names need to be capitalized. So, this is where the magic happens - you do not need to define the class in Ruby the &#8220;hard-way&#8221;. You define the class variables (so-called states) only once - in the database, and then those variables are automatically recognized by Rails and a standard CRUD framework is applied, which you can replace with your own code as you go.</p>
<p>3. Finally, check that everything works by going to this link: <a href="http://127.0.0.1:3000/stories/">http://127.0.0.1:3000/stories/</a></p>
<p>For fun, try creating, updating and deleting records and see how the table records are automatically updated in the MySQL CC or Query Browser.</p>
<p><strong>IN CONCLUSION<br />
</strong>Installing Ruby on Rails is not a difficult process, but it takes some time. However, once installed you will not only feel comfortable with basic MySQL administration, but will also get a development environment which is much faster and easier to use than a hosting based alternative. Once you create a web service that can be released to public, you can easily move it to one of <a href="http://wiki.rubyonrails.com/rails/pages/RailsWebHosts">the Rails hosting providers</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=16&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/09/installing-rails-on-windows-step-by-step-tutorial/feed/</wfw:commentRss>
	
		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p1.jpg" medium="image">
			<media:title type="html">p1.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p2.jpg" medium="image">
			<media:title type="html">p2.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p3.jpg" medium="image">
			<media:title type="html">p3.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p4.jpg" medium="image">
			<media:title type="html">p4.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p5.jpg" medium="image">
			<media:title type="html">p5.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p61.jpg" medium="image">
			<media:title type="html">p61.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p7.jpg" medium="image">
			<media:title type="html">p7.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p8.jpg" medium="image">
			<media:title type="html">p8.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p9.jpg" medium="image">
			<media:title type="html">p9.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p10.jpg" medium="image">
			<media:title type="html">p10.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p11.jpg" medium="image">
			<media:title type="html">p11.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p12.jpg" medium="image">
			<media:title type="html">p12.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p131.jpg" medium="image">
			<media:title type="html">p131.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p14.jpg" medium="image">
			<media:title type="html">p14.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p15.jpg" medium="image">
			<media:title type="html">p15.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p16.jpg" medium="image">
			<media:title type="html">p16.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p17.jpg" medium="image">
			<media:title type="html">p17.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p18.jpg" medium="image">
			<media:title type="html">p18.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p21.jpg" medium="image">
			<media:title type="html">p21.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p19.jpg" medium="image">
			<media:title type="html">p19.jpg</media:title>
		</media:content>

		<media:content url="http://allaboutruby.files.wordpress.com/2006/01/p22.jpg" medium="image">
			<media:title type="html">p22.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Do you need instant rails?</title>
		<link>http://allaboutruby.wordpress.com/2006/01/08/do-you-need-instant-rails/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/08/do-you-need-instant-rails/#comments</comments>
		<pubDate>Sun, 08 Jan 2006 16:41:23 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/08/do-you-need-instant-rails/</guid>
		<description><![CDATA[I have written about the Instantrails package before, but having tried it for a day, I decided to go with a proper installation. The reason for this is that I&#8217;ve never used to run either MySQL or Apache on my local computer, and as I have all sorts of firewalls and quirks on my computer, [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have written about the Instantrails package before, but having tried it for a day, I decided to go with a proper installation. The reason for this is that I&#8217;ve never used to run either MySQL or Apache on my local computer, and as I have all sorts of firewalls and quirks on my computer, when things went wrong, I did not understand how I could fix them. Instantrails does not have any real documentation and I was not sure what exactly went wrong.</p>
<p>Also, Instantrails comes with phpmyadmin for MySQL admin, and for this it also needs to install php, which I thought was excessive - I&#8217;d rather go with my old trusted MySQL Control Center or the new Query Browser. So, if you are not a power user of either MySQL or Apache, I would recommend <strong>against</strong> using InstantRails.</p>
<p>Finally, for development you do not need to install Apache, as Rails comes with WEBrick, which should do the job good enough.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/36/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/36/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=36&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/08/do-you-need-instant-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Great way to start with Ruby</title>
		<link>http://allaboutruby.wordpress.com/2006/01/06/great-way-to-start-with-ruby/</link>
		<comments>http://allaboutruby.wordpress.com/2006/01/06/great-way-to-start-with-ruby/#comments</comments>
		<pubDate>Fri, 06 Jan 2006 21:21:17 +0000</pubDate>
		<dc:creator>allaboutruby</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://allaboutruby.wordpress.com/2006/01/06/great-way-to-start-with-ruby/</guid>
		<description><![CDATA[Yes, books&#8230;
I have purchased the &#8220;Programming Ruby&#8221; Book from Pragmatic Programmers, and based on what I&#8217;ve read (I&#8217;ve read around 60 pages up to now) - this is an excellent book that guides you through Ruby from the very beginning (you do not even need to know what classes and methods are) to the very [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yes, books&#8230;</p>
<p>I have purchased the &#8220;<a href="http://pragmaticprogrammer.com/titles/ruby/index.html" target="_blank">Programming Ruby</a>&#8221; Book from Pragmatic Programmers, and based on what I&#8217;ve read (I&#8217;ve read around 60 pages up to now) - this is an excellent book that guides you through Ruby from the very beginning (you do not even need to know what classes and methods are) to the very end (which is a long section describing methods). I recommend everyone to purchase it on-line, and while there, you can consider also purchasing their <a href="http://pragmaticprogrammer.com/titles/ajax/index.html" target="_blank">Ajax</a> and <a href="http://pragmaticprogrammer.com/titles/rails/index.html" target="_blank">Rails</a> books (I haven&#8217;t bought them yet, but they are high on my wishlist).</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/allaboutruby.wordpress.com/39/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/allaboutruby.wordpress.com/39/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/allaboutruby.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/allaboutruby.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/allaboutruby.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/allaboutruby.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/allaboutruby.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/allaboutruby.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/allaboutruby.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/allaboutruby.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/allaboutruby.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/allaboutruby.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=allaboutruby.wordpress.com&blog=56213&post=39&subd=allaboutruby&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://allaboutruby.wordpress.com/2006/01/06/great-way-to-start-with-ruby/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>