<?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>MatthewVBruby tutorials | MatthewVB</title>
	<atom:link href="http://www.matthewvb.me/category/ruby-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matthewvb.me</link>
	<description></description>
	<lastBuildDate>Sun, 27 Nov 2011 02:36:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Easy Ruby/Flash Image Scroller</title>
		<link>http://www.matthewvb.me/2008/02/24/easy-rubyflash-image-scroller/</link>
		<comments>http://www.matthewvb.me/2008/02/24/easy-rubyflash-image-scroller/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 20:49:58 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=109</guid>
		<description><![CDATA[<p>I was recently working on a project where I had a series of pictures I wanted to display in a nice scroll across the screen, complete with the ability to have captions and link pictures to other pages. I stumbled across <a href="http://www.benjaminkeen.com/">BenjaminKeen&#8217;s</a> <a href="http://www.benjaminkeen.com/software/image_scroller/">Image Scroller</a> and decided to give it a whirl. It&#8217;s a really simple solution and here&#8217;s how I went about implementing it in rails. (Oh, it&#8217;s free too!) We&#8217;re going to use an XML feed to pull the data in for our images.</p>
<p>Here&#8217;s what our finished product will look like:<br />
<br />
<strong>Getting Started</strong><br />
1. <a href="http://www.benjaminkeen.com/software/image_scroller/">Download Source</a> (download / old version link)Once downloaded, created a folder called <em>image_scroller</em> inside your public folder. Then, place: <em>scroller_x.swf</em> and <em>swf_object.js</em> inside the image_scroller folder. The rest of &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I was recently working on a project where I had a series of pictures I wanted to display in a nice scroll across the screen, complete with the ability to have captions and link pictures to other pages. I stumbled across <a href="http://www.benjaminkeen.com/">BenjaminKeen&#8217;s</a> <a href="http://www.benjaminkeen.com/software/image_scroller/">Image Scroller</a> and decided to give it a whirl. It&#8217;s a really simple solution and here&#8217;s how I went about implementing it in rails. (Oh, it&#8217;s free too!) We&#8217;re going to use an XML feed to pull the data in for our images.</p>
<p>Here&#8217;s what our finished product will look like:<br />
<object height="122" width="427"><param name="movie" value="http://www.matthewvb.me/wp-content/uploads/2008/02/2008-02-23_1620.swf"></param><embed src="http://www.matthewvb.me/wp-content/uploads/2008/02/2008-02-23_1620.swf" height="122" width="427"></embed></object><br />
<strong>Getting Started</strong><br />
1. <a href="http://www.benjaminkeen.com/software/image_scroller/">Download Source</a> (download / old version link)Once downloaded, created a folder called <em>image_scroller</em> inside your public folder. Then, place: <em>scroller_x.swf</em> and <em>swf_object.js</em> inside the image_scroller folder. The rest of the files you really don&#8217;t need for what we&#8217;re doing.</p>
<p>2. Insert the code onto your page.</p>
<p>Open up the view file you want to place the code on. Insert the following code to get the project rolling:<br />
<code>  &lt;div id="scroller2" style="width:375px; height: 66px;"&gt;<br />
Your browser is not able to run this Flash script.&lt;br /&gt;<br />
&lt;br /&gt;<br />
Requirements: &lt;br /&gt;<br />
- JavaScript must be enabled&lt;br /&gt;<br />
- You must have Flash installed&lt;br /&gt;</code></p>
<p><code>&lt;script type="text/javascript"&gt;<br />
var so2 = new SWFObject("/image_scroller/scroller_x.swf", "scroller2", "100%", "90", "8");</code></p>
<p><code>so2.addVariable("sourceFile", "&lt;%= url_for :controller =&gt; 'teamhub', :action =&gt; 'faces_photos', :sport_id =&gt; @sport.id %&gt;");<br />
so2.addVariable("fileType", "XML");<br />
so2.addVariable("scrollSpeed", "10");<br />
so2.addVariable("stageWidth", "375");<br />
so2.addVariable("stageHeight", "75");<br />
so2.addVariable("thumbSize", "50");<br />
so2.addVariable("bgColor", "ffffff");<br />
so2.addVariable("navColor", "000000");<br />
so2.addVariable("autoScroll", "no");<br />
so2.addVariable("thumbBackgroundColor", "ffffff");<br />
so2.addVariable("thumbBackgroundOpacity", "100");<br />
so2.addVariable("captionAlign", "left");<br />
so2.write("scroller2");<br />
&lt;/script&gt;<br />
&lt;/div&gt;</code></p>
<p>A few notes about the code above:</p>
<ul>
<li>The first line let&#8217;s you specify the height and width of the object.</li>
<li>Inside the javascript, you see: <em>var so2 = new SWFObject(&#8220;/image_scroller/scroller_x.swf&#8221;, &#8220;scroller2&#8243;, &#8220;100%&#8221;, &#8220;90&#8243;, &#8220;8&#8243;); </em>The params of the SWFObject are calling for the following: (<em>source location, the name of your scroller object&#8217;s div id, width to occupy, height to occupy, version of the image_scroller software</em>).</li>
<li>Following this you see the first line of addVariable:   <em>so2.addVariable(&#8220;sourceFile&#8221;, &#8220;&lt;%= url_for :controller =&gt; &#8216;user&#8217;, :action =&gt; &#8216;faces_photos&#8217;, :user_id=&gt; @user.id %&gt;&#8221;);</em> The ruby code inside of here is pulling out the XML. note the controller, action, and ID for the info we want to pull in. In this case, we have a user controller, an action faces_photos which pulls our photo array for the user with the id of @user.id.</li>
<li>All the rest of great customizations that you can add to your scroller. BenjaminKeen <a href="http://www.benjaminkeen.com/software/image_scroller/">documents</a> <a href="http://www.benjaminkeen.com/software/image_scroller/"> </a>(configuration link) them all and what you can do with them. For this example, you have to keep the fileType of XML present.</li>
</ul>
<p><strong>Ruby Controller</strong></p>
<p>We&#8217;ve used attachment_fu to upload all of our images (see <a href="http://clarkware.com/cgi/blosxom/2007/02/24">Mike Clark&#8217;s tutorial</a>). Here&#8217;s what our controller looks like:<br />
<code> def faces_photos<br />
@userphotos= Userphoto.find(:all, :conditions =&gt; ['thumbnail IS ? AND user_id = ?', nil, params[:user_id]])<br />
render :layout =&gt; false<br />
end</code></p>
<p>A quick break down:</p>
<ul>
<li>Our first line pulls the array of user photos for that user. We search for thumbnail IS nil so that we don&#8217;t pull all the different versions of the photo that attachmenu_fu created for us.</li>
<li>The second line is also important, as it says not to use our layout, cause we&#8217;re going to use XML.</li>
</ul>
<p><strong>XML View</strong></p>
<p>We need an XML file which we&#8217;ve called faces_photos.rxml. Here&#8217;s what it looks like:<br />
<code> xml.items{<br />
for photo in @userphotos<br />
xml.item{<br />
xml.thumbURL(photo.user.userphoto.public_filename(:thumb))<br />
xml.linkURL(url_for :controller =&gt; :portal, :action =&gt; :view_profile, :username =&gt; photo.user.username)<br />
}<br />
end<br />
}</code></p>
<p>What we&#8217;re doing is cycling through all the photos in our @userphotos array. We have a few things we&#8217;re putting into our items list:</p>
<ul>
<li><em>thumbURL</em>: this is the link to the location of the thumbnail image (or whatever image you want to use in the scroller)</li>
<li><em>linkURL: </em>an optional item, this is where clicking on the image in the scroller will take you. In this case, we&#8217;re going to the user&#8217;s profile.</li>
<li><em>caption</em>:  A caption for the photo, also optional. We didn&#8217;t put one in this example, but you could throw in the title of the picture quite easily that then displays below the photo.</li>
</ul>
<p>With this, we&#8217;re all set! Customize your scroller to be user it&#8217;s what you want and give it a run.</p>
<p><strong>Common Errors</strong></p>
<ol>
<li>Photos aren&#8217;t displaying: Double check your XML file and be sure you&#8217;re constructing it the right away. A good test is to browse to the xml file itself to see if the links are correct. In this example, we&#8217;d browse to controller\faces_photos.xml\3</li>
<li>When you scroller, images are appearing outside the box: You have a problem with your widths not matching. Make sure all the places where width is listed are matching; there&#8217;re 3 locations: the div id line, the creation of the SWF object line, and finally the configuration of the scroller.</li>
</ol>
<p>Enjoy your new image scroller and using Ruby to got to play with some XML. A few more XML tutorials will be coming as I show you how to put some killer charts and maps onto your app in the upcoming weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2008/02/24/easy-rubyflash-image-scroller/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby &amp; Charts getting together</title>
		<link>http://www.matthewvb.me/2007/10/04/ruby-charts-getting-together/</link>
		<comments>http://www.matthewvb.me/2007/10/04/ruby-charts-getting-together/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 18:45:57 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=70</guid>
		<description><![CDATA[<p><img align="right" src="http://amcharts.com/images/logo.gif" />I&#8217;ve recently fallen in love with <a href="http://amcharts.com/">amcharts</a>, a great little flash package that allows you to create kick-pants charts on your site. I&#8217;m still experimenting with all the possibilities it can do, but then I came across this great post by <a href="http://www.railsontherun.com/2007/10/4/sexy-charts-in-less-than-5-minutes">Matt Aimonetti</a> [<a href="http://www.railsontherun.com/">Rails on the Run</a>] and it all becomes much easier.</p>
<p>I highly recommend checking out <a href="http://amcharts.com/">amcharts</a>. It&#8217;s gonna be an amazing tool for not only ruby charts, but any charting needs you have that can use XML.</p>
<p><img width="309" height="59" align="right" src="http://railscasts.com/images/logo.png?1191241836" />Hopefully I&#8217;ll write a bit more about ruby in the upcoming months &#8212; sorry for the lack of tutorials. In the meantime, I highly recommend <a href="http://railscasts.com/">Ryan&#8217;s railscast&#8217;s</a>. It&#8217;s a great video-podcast with over 70 short, quick, and highly useful tutorials.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><img align="right" src="http://amcharts.com/images/logo.gif" />I&#8217;ve recently fallen in love with <a href="http://amcharts.com/">amcharts</a>, a great little flash package that allows you to create kick-pants charts on your site. I&#8217;m still experimenting with all the possibilities it can do, but then I came across this great post by <a href="http://www.railsontherun.com/2007/10/4/sexy-charts-in-less-than-5-minutes">Matt Aimonetti</a> [<a href="http://www.railsontherun.com/">Rails on the Run</a>] and it all becomes much easier.</p>
<p>I highly recommend checking out <a href="http://amcharts.com/">amcharts</a>. It&#8217;s gonna be an amazing tool for not only ruby charts, but any charting needs you have that can use XML.</p>
<p><img width="309" height="59" align="right" src="http://railscasts.com/images/logo.png?1191241836" />Hopefully I&#8217;ll write a bit more about ruby in the upcoming months &#8212; sorry for the lack of tutorials. In the meantime, I highly recommend <a href="http://railscasts.com/">Ryan&#8217;s railscast&#8217;s</a>. It&#8217;s a great video-podcast with over 70 short, quick, and highly useful tutorials.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/10/04/ruby-charts-getting-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>delays are just inevitable</title>
		<link>http://www.matthewvb.me/2007/05/18/delays-are-just-inevitable/</link>
		<comments>http://www.matthewvb.me/2007/05/18/delays-are-just-inevitable/#comments</comments>
		<pubDate>Fri, 18 May 2007 04:30:23 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[hopes & dreams]]></category>
		<category><![CDATA[programming stuff]]></category>
		<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=38</guid>
		<description><![CDATA[<p>I realize I said a few weeks ago that I&#8217;d have a tutorial up for the next step in the <a href="http://www.ruser.webtomic.com">ruby member management system</a>. The good and the bad:</p>
<p>The bad: I didn&#8217;t get the tutorial done.</p>
<p>The good: I&#8217;ve got a system in development that goes live this fall which uses ruser as a platform. I&#8217;m super excited because I have some interest and potential investors happening with it! That&#8217;ll be news later this summer.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I realize I said a few weeks ago that I&#8217;d have a tutorial up for the next step in the <a href="http://www.ruser.webtomic.com">ruby member management system</a>. The good and the bad:</p>
<p>The bad: I didn&#8217;t get the tutorial done.</p>
<p>The good: I&#8217;ve got a system in development that goes live this fall which uses ruser as a platform. I&#8217;m super excited because I have some interest and potential investors happening with it! That&#8217;ll be news later this summer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/05/18/delays-are-just-inevitable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>minor updates to ruser</title>
		<link>http://www.matthewvb.me/2007/04/09/minor-updates-to-ruser/</link>
		<comments>http://www.matthewvb.me/2007/04/09/minor-updates-to-ruser/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 02:35:45 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=30</guid>
		<description><![CDATA[<p>Those following the development of <a href="http://www.ruser.webtomic.com">ruser</a> will be happy to note a few things:</p>
<ul>
<li>I&#8217;ve added dynamic pages to the ability of the admin. Needs some fine-tuning, but very cool and powerful. Great for an &#8216;about&#8217; page or a &#8216;faq&#8217; page.</li>
<li>I&#8217;m seriously going to start working on the next installment of the tutorial. I had a bit of a distraction of applying to an MBA program and then a trip to Orlando for a conference. Well, I&#8217;m back and ready to get going!</li>
</ul>
<p>On the logged-in page of ruser, you&#8217;ll be able to see what&#8217;s left to be developed before the first official release. An ever changing list, hopefully it&#8217;ll be done in the next month.  Then ruser will be implemented in the its &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Those following the development of <a href="http://www.ruser.webtomic.com">ruser</a> will be happy to note a few things:</p>
<ul>
<li>I&#8217;ve added dynamic pages to the ability of the admin. Needs some fine-tuning, but very cool and powerful. Great for an &#8216;about&#8217; page or a &#8216;faq&#8217; page.</li>
<li>I&#8217;m seriously going to start working on the next installment of the tutorial. I had a bit of a distraction of applying to an MBA program and then a trip to Orlando for a conference. Well, I&#8217;m back and ready to get going!</li>
</ul>
<p>On the logged-in page of ruser, you&#8217;ll be able to see what&#8217;s left to be developed before the first official release. An ever changing list, hopefully it&#8217;ll be done in the next month.  Then ruser will be implemented in the its first application&#8230;which will be announced in the upcoming months.</p>
<p>Thanks all! Catch ya around the blogosphere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/04/09/minor-updates-to-ruser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ROR User System: Part 2 &#8211; Generic Registration Time</title>
		<link>http://www.matthewvb.me/2007/02/11/ror-user-system-part-2-generic-registration-time/</link>
		<comments>http://www.matthewvb.me/2007/02/11/ror-user-system-part-2-generic-registration-time/#comments</comments>
		<pubDate>Mon, 12 Feb 2007 03:35:20 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=20</guid>
		<description><![CDATA[<p>Today we continue our adventure in Ruby creating a <a href="http://www.matthewvb.com/?p=18">Last time</a> we set-up the general background support for the system. Today, we&#8217;re going to make some magic appear on the screen, and get some data on our pages.</p>
<p><strong>Making it Run</strong></p>
<p>To get started, let&#8217;s just make sure we have things all well in the Ruby world. You should still have a command prompt open and your favorite editor. In the command prompt, let&#8217;s do the following:</p>
<p><code>ruby script/server</code></p>
<p>You just started the ruby server on your computer. Where did it come from? From when you installed ruby of course! Now, go to your <a href="http://www.mozilla.com/en-US/firefox/">internet browser</a> and enter:</p>
<p><code>http://localhost:3000/</code></p>
<p>This is the address of your local machine and the ruby server. You should see something &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Today we continue our adventure in Ruby creating a <a href="http://www.matthewvb.com/?p=18">Last time</a> we set-up the general background support for the system. Today, we&#8217;re going to make some magic appear on the screen, and get some data on our pages.</p>
<p><strong>Making it Run</strong></p>
<p>To get started, let&#8217;s just make sure we have things all well in the Ruby world. You should still have a command prompt open and your favorite editor. In the command prompt, let&#8217;s do the following:</p>
<p><code>ruby script/server</code></p>
<p>You just started the ruby server on your computer. Where did it come from? From when you installed ruby of course! Now, go to your <a href="http://www.mozilla.com/en-US/firefox/">internet browser</a> and enter:</p>
<p><code>http://localhost:3000/</code></p>
<p>This is the address of your local machine and the ruby server. You should see something like this:</p>
<p><img width="485" height="310" align="right" id="image21" alt="Ruby Running Screenshot" src="http://www.matthewvb.me/wp-content/uploads/2007/02/ruby-running.gif" /></p>
<p>Yah! It works! Okay now. Time to get this thing going.</p>
<p><strong>Setting Up the Controller &#8212; just like a remote control</strong></p>
<p>The time has come to see something on the screen. For this project, we&#8217;re going to really just focus on using one controller. Remember, a controller is the gateway between what the user sees and interacting with the database. We&#8217;re going to use this project as a portal for other projects, so, let&#8217;s call the controller: portal.</p>
<p>Open another command prompt (leaving the other one opening and running) and in your command prompt, type the following:</p>
<p><code>ruby script/generate controller portal</code></p>
<p>This will run and create a handful of things in your project. The main thing this will create, in the app folder, a controller! Yah! (That was our goal and all.) You&#8217;ll notice the file is called: portal_controller.rb. The convention in ruby is to use the underscore for files/variables/etc with multiple words. Notice we also have a folder under app for views called portal. This will come in handy in a little bit.</p>
<p>Open the portal_controller.rb file and let&#8217;s get some things going. When you start, you&#8217;ll see just this:</p>
<p><code>class PortalController < ApplicationController<br />
end</code></p>
<p>Just like any other coding language, everything we code has a beginning and an <em>end</em>. In ruby, we use the term <em>end</em> as our ender. In our file, let's add the following in between the class and end lines:</p>
<p><code>scaffold :user</code></p>
<p>This will create a real generic scaffold (set of guides) for our portal controller using the user class. Now, we can play around with our file and still have functionality. Point your browser to: http://localhost:3000/portal. In ruby, we put the controller we want to use after the localhost:3000. So, if we wanted to look at a zoo_keeper controller, we'd browse to: localhost:3000/zoo_keeper.</p>
<p>You should see this:</p>
<p><img width="400" alt="Listing Users - Scaffold" id="image22" src="http://www.matthewvb.me/wp-content/uploads/2007/02/listing-users.gif" /></p>
<p>Sure, it's nothing pretty -- but it <em>is</em> pretty cool. With the scaffold being used, we have created a simple CRUD interface. No, not nasty grim, CRUD - Create, Read, Update, and Delete. With this we can add new records, view records, edit, and delete them. Go ahead, click around, add some files. Here we've added a user and you can see he now has show, edit, and delete functions.</p>
<p><img style="width: 511px; height: 174px" alt="List w/ Bob Newhart" id="image23" src="http://www.matthewvb.me/wp-content/uploads/2007/02/list-1.gif" /></p>
<p>Notice the nice green message at the top -- Ruby is great at keeping us posted with what's going on. In this case, we've successfully created a user.</p>
<hr />Play around a bit with the site. Next time we're going to make it do a few more things which we'll need it to do -- like make sure any required fields are completed, making the password secret, and adding our safety net for account deletion. Until then!<em>Note: You can right-click and view image to see the a better image resolution. Next time I'll probably be putting these on a video, so we'll not have this prob again.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/02/11/ror-user-system-part-2-generic-registration-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ROR User System Tutorial: Part 1 &#8211; Setting it all up</title>
		<link>http://www.matthewvb.me/2007/01/28/ror-user-system-tutorial-part-1-setting-it-all-up/</link>
		<comments>http://www.matthewvb.me/2007/01/28/ror-user-system-tutorial-part-1-setting-it-all-up/#comments</comments>
		<pubDate>Sun, 28 Jan 2007 04:26:21 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=18</guid>
		<description><![CDATA[<p>As I <a href="http://www.matthewvb.com/?p=15">mentioned before</a>, I&#8217;m going to work on publishing a ROR User System Tutorial (RoRUST for short) that will let you create a fully managed user system. People will be able to login, edit profiles, create admins, and much more. I&#8217;m very excited to share some wisdom back to the community. So, here we go!</p>
<p>Today&#8217;s goal: set up the basics so we can start playing with the actual system! (feel free to fast forward through what you know, but we&#8217;ll take it slow for those following along.)<br />
Note: This is all done on a windows machine. Some Mac things may vary&#8230;but I&#8217;m sure you&#8217;ll figure out what needs to happen&#8230;</p>
<p><strong>Setting up the Directory</strong></p>
<p>Throughout this process you&#8217;ll need a command prompt &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>As I <a href="http://www.matthewvb.com/?p=15">mentioned before</a>, I&#8217;m going to work on publishing a ROR User System Tutorial (RoRUST for short) that will let you create a fully managed user system. People will be able to login, edit profiles, create admins, and much more. I&#8217;m very excited to share some wisdom back to the community. So, here we go!</p>
<p>Today&#8217;s goal: set up the basics so we can start playing with the actual system! (feel free to fast forward through what you know, but we&#8217;ll take it slow for those following along.)<br />
Note: This is all done on a windows machine. Some Mac things may vary&#8230;but I&#8217;m sure you&#8217;ll figure out what needs to happen&#8230;</p>
<p><strong>Setting up the Directory</strong></p>
<p>Throughout this process you&#8217;ll need a command prompt open. Keep it open &#8212; as we&#8217;ll come back to it often. I recommend having a folder in C:\ called rails to host most of your files. in the C:\rails directory, start a new rails program</p>
<p><code>rails membership</code></p>
<p>This will create all the directory files for a new rails project.</p>
<p>Next, create the user model. (The model will handle the passing of information between the program and the database.) First, go into your rails project at the command prompt (<code>cd membership</code>) and then At the command prompt:</p>
<p><code>ruby script/generate model user</code></p>
<p>Model created! Rails is smart and knows that because we named this model user, it&#8217;s going to interact with our users table. Rails can add the plurals to your models and is smart. Just remember that &#8212; rails is smart.<br />
You can now use your favorite editor to mess with the files (I use <a href="http://www.radrails.org">RadRails</a>) we just created.</p>
<p>First thing we&#8217;re going to do is set up our database. The <em>key</em> to a great ruby program is being intentional and well-planned with your database. Your database will drive your program and make life so much easier. You should always plan what you want to do.</p>
<p>You need to set-up a database to do your damage. You&#8217;ll need to do this one own, but call it: membership_development. You should then go into your editor and go to: config\database.yml and edit the code to fit your new database name, username, and password.</p>
<p>Now, to start setting it all up.</p>
<p>In your editor, go to: db\migrate\ and you should see a file labeled 001_something_or_other. These are migrations set to make your database manipulation much easier. You&#8217;ll be able to add more migrations later and continue to add to your database through rails.</p>
<p>Edit the 001 file to be the following:</p>
<p><code>def self.up<br />
</code></p>
<blockquote><p><code>create_table "users" do |t|</code><br />
<code /></p>
<blockquote><p><code>t.column "username", :string, :limit => 24, :default => "", :null => false</code><br />
<code> t.column "hashed_password", :string</code><br />
<code> t.column "first_name", :string</code><br />
<code> t.column "last_name", :string</code><br />
<code> t.column "email", :string</code><br />
<code> t.column "url", :string</code><br />
<code /></p></blockquote>
<p><code>end</code><code /><br />
<code /></p></blockquote>
<p><code>end</code></p>
<p><code>def self.down<br />
</code></p>
<blockquote><p><code>drop_table :users</code><code /><br />
<code /></p></blockquote>
<p><code>end </code></p>
<p>We're gonna add the following fields to our user database -- fields we'll want to use throughout our project (username, firstname, etc.). Notice we didn't have to put an ID field into our database -- rails will do that for us.</p>
<p>Now, to make this changes to the database, we need to go back to our command prompt:</p>
<p><strike><code>rake migration<br />
</code></strike><code>rake migrate</code><strike><code><br />
</code></strike></p>
<p>This will force everything in our migration files to update the database to the latest*(see note below regarding newer rails versions). Rails allows you to do a great things:</p>
<ul>
<li>Allow you to go forward and backward in your database iterations. Make a mistake? easy - you can go backwards. You can also push forward.</li>
</ul>
<p>The self.up are the files that are created when you move forward. If you go backward, the self.down kicks in. More about this later.</p>
<p>Now we have a database with fields and we're ready to start playing with our model, but one more thing we're going to set up is our controller.</p>
<p>A controller builds the relationship between the user and the model. A controller can interact with many models, for this program, we're going to call ours "portal" -- something that can be our gateway to information.</p>
<p>Back to the command prompt we go:</p>
<p><code>ruby script/generate controller portal</code></p>
<p>Now we have a controller. Notice when you refresh your file directory in your editor that a few more files have been created. We have controllers, helpers, and more views now. We'll play with these all in good time.</p>
<hr />Alright, that's a good starting point. Lots of jumping around and nothing to show for it, yet. Trust me, this set up is well worth the time it will take in the end. Programmers are saying that a usual 10 month project in Java can be completed in 3 weeks in Ruby. You'll love what Ruby has to offer.Hopefully you're starting to learn a little ruby. This will be a great tutorial to jump you ahead of the crowd.<span style="font-weight: bold">What's coming next time?</span>Next time we're going to work on getting our controller and model playing together. By the end of next time we'll have our first steps of a user system, including starting to register users.Let me know if you have any questions -- I'll be back in about a week with Part 2.<em>Update: Fixed migration error noted above -- should be "rake migrate"</em><em>*Note: Those using new versions of rails may need to use: "rake db:migrate" instead of "rake migrate" -- which I've learned is being depreciated.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/01/28/ror-user-system-tutorial-part-1-setting-it-all-up/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ROR user system note</title>
		<link>http://www.matthewvb.me/2007/01/11/ror-user-system-note/</link>
		<comments>http://www.matthewvb.me/2007/01/11/ror-user-system-note/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 02:03:18 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[programming stuff]]></category>
		<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=16</guid>
		<description><![CDATA[<p>Just a quick note on the upcoming tutorial series. Due to my current work load and spring training of employees, I&#8217;ll be launching the tutorial series probably the last week of January.</p>
<p>Also &#8211; I updated the ROR tutorials to be tagged with ruby tutorial categories instead of &#8220;programming stuff.&#8221;</p>
<p>(Probably won&#8217;t have many posts till then either&#8230;sorry!)&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Just a quick note on the upcoming tutorial series. Due to my current work load and spring training of employees, I&#8217;ll be launching the tutorial series probably the last week of January.</p>
<p>Also &#8211; I updated the ROR tutorials to be tagged with ruby tutorial categories instead of &#8220;programming stuff.&#8221;</p>
<p>(Probably won&#8217;t have many posts till then either&#8230;sorry!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/01/11/ror-user-system-note/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>User Login System &#8211; ROR Style</title>
		<link>http://www.matthewvb.me/2007/01/03/user-login-system-ror-style/</link>
		<comments>http://www.matthewvb.me/2007/01/03/user-login-system-ror-style/#comments</comments>
		<pubDate>Wed, 03 Jan 2007 04:41:30 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=15</guid>
		<description><![CDATA[<p>I&#8217;ve been working on a really generic ROR user interface. (It&#8217;s all part of an alumni system I&#8217;m making for my <a href="http://www.beaverdam.k12.wi.us/pages/high_school.cfm">high school</a> graduating class.) I&#8217;m going to be going into a few tutorials over the next week or so on how to set it up and understand what&#8217;s happening. I know that there are some books out there already (<a href="http://www.amazon.com/gp/product/0974514055?ie=UTF8&#038;tag=matthewvb-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0974514055">Programming Ruby: The Pragmatic Programmers&#8217; Guide</a> being a great starting point and also  <a href="http://www.amazon.com/gp/product/0596101325?ie=UTF8&#038;tag=matthewvb-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596101325">Ruby on Rails: Up and Running</a>) Here are some of the features that I&#8217;ll share (in no particular order):</p>
<ul>
<li>registration with validation</li>
<li>user list with: viewing of profiles, denotation of admins</li>
<li>updating personal profile and deleting profile</li>
<li>updating password with old password validation</li>
<li>login/out functions</li>
<li>and perhaps more&#8230;</li>
</ul>
<p>Eventually I&#8217;ll &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a really generic ROR user interface. (It&#8217;s all part of an alumni system I&#8217;m making for my <a href="http://www.beaverdam.k12.wi.us/pages/high_school.cfm">high school</a> graduating class.) I&#8217;m going to be going into a few tutorials over the next week or so on how to set it up and understand what&#8217;s happening. I know that there are some books out there already (<a href="http://www.amazon.com/gp/product/0974514055?ie=UTF8&#038;tag=matthewvb-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0974514055">Programming Ruby: The Pragmatic Programmers&#8217; Guide</a> being a great starting point and also  <a href="http://www.amazon.com/gp/product/0596101325?ie=UTF8&#038;tag=matthewvb-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596101325">Ruby on Rails: Up and Running</a>) Here are some of the features that I&#8217;ll share (in no particular order):</p>
<ul>
<li>registration with validation</li>
<li>user list with: viewing of profiles, denotation of admins</li>
<li>updating personal profile and deleting profile</li>
<li>updating password with old password validation</li>
<li>login/out functions</li>
<li>and perhaps more&#8230;</li>
</ul>
<p>Eventually I&#8217;ll add some other cool features, like adding an events and posting announcements &#8212; those will come in the long term (so don&#8217;t sit up waiting for them).</p>
<p>Here comes some more tutorials into one cool system &#8212; which I&#8217;m making as we go along.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2007/01/03/user-login-system-ror-style/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>del.icio.us on Rails (and other XML feeds)</title>
		<link>http://www.matthewvb.me/2006/12/20/delicious-on-rails-and-other-xml-feeds/</link>
		<comments>http://www.matthewvb.me/2006/12/20/delicious-on-rails-and-other-xml-feeds/#comments</comments>
		<pubDate>Thu, 21 Dec 2006 03:06:50 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=14</guid>
		<description><![CDATA[<p>Here&#8217;s some quick and dirty information on how to include an XML feed into your ruby site.</p>
<p><strong>Install &#038; Implement Gem</strong></p>
<p>Begin by installing the <a href="http://sporkmonger.com/projects/feedtools/">feed_tools gem</a>.</p>
<p><code>gem install feedtools</code></p>
<p>In the environment.rb file, include at the bottom:</p>
<p><code>require 'feed_tools'</code></p>
<p><strong>Using the Gem</strong></p>
<p>In your <em>controller</em>, pick a method (mine sits inside <em>view</em>) and implement a new feed: (This pulls my del.icio.us feed)<br />
<code>@feed = FeedTools::Feed.open("http://del.icio.us/rss/matthewvb")</code></p>
<p>Then, I like to add some pagination, cause I don&#8217;t want all the info, just the latest:</p>
<p><code>@pages, @items = paginate_collection @feed.items, :page =@params[:page]</code></p>
<p>Finally, render it partially (this will display each instance of your XML data &#8212; basically it does the looping through the array for you)<br />
<code>render :partial ="feed"</code></p>
<p><strong>Pagnation</strong></p>
<p>I used &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some quick and dirty information on how to include an XML feed into your ruby site.</p>
<p><strong>Install &#038; Implement Gem</strong></p>
<p>Begin by installing the <a href="http://sporkmonger.com/projects/feedtools/">feed_tools gem</a>.</p>
<p><code>gem install feedtools</code></p>
<p>In the environment.rb file, include at the bottom:</p>
<p><code>require 'feed_tools'</code></p>
<p><strong>Using the Gem</strong></p>
<p>In your <em>controller</em>, pick a method (mine sits inside <em>view</em>) and implement a new feed: (This pulls my del.icio.us feed)<br />
<code>@feed = FeedTools::Feed.open("http://del.icio.us/rss/matthewvb")</code></p>
<p>Then, I like to add some pagination, cause I don&#8217;t want all the info, just the latest:</p>
<p><code>@pages, @items = paginate_collection @feed.items, :page => @params[:page]</code></p>
<p>Finally, render it partially (this will display each instance of your XML data &#8212; basically it does the looping through the array for you)<br />
<code>render :partial => "feed"</code></p>
<p><strong>Pagnation</strong></p>
<p>I used a pagination above which pulls from <em>application.rb </em>(The application controller). I pulled this <a href="http://www.bigbold.com/snippets/tag/pagination">online</a>.</p>
<p><code>  def paginate_collection(collection, options = {})<br />
default_options = {:per_page => 5, :page => 1}<br />
options = default_options.merge options<br />
pages = Paginator.new self, collection.size, options[:per_page], options[:page]<br />
first = pages.current.offset<br />
last = [first + options[:per_page], collection.size].min<br />
slice = collection[first...last]<br />
return [pages, slice]<br />
end</code></p>
<p>Note the second line; here is where you can specify how many items to display and how many pages. I just pulled 5 to keep the list short.</p>
<p><strong>View</strong></p>
<p>In the partial rendering file (<em>_feed.rhtml)</em>, I have the following code, specific to the feed I&#8217;m pulling:</p>
<p><code> <% for item in @items %><br />
<%= item.description %><br />
<% end %></code></p>
<p>Here&#8217;s what&#8217;s happening:</p>
<p>First, we&#8217;ll set up our loop for going through all the items in the array. @items was defined in the controller</p>
<p><code> <% for item in @items %></code></p>
<p>Finally, I display the description tag of the XML file and close my loop.<br />
<code><%= item.description %><br />
<% end %></code></p>
<p><s><strong>XML File Sample</strong></s></p>
<p><s>Here&#8217;s what some of the XML looks like that we have pulled:</s></p>
<p><s>You can pull all these things just by using the item.____ command.</s></p>
<p>Enjoy pulling feeds! (See my <a href="http://www.matthewvb.com/?p=6">info on implementing flickr on ruby</a> for more info on that.)</p>
<p><span style="font-style: italic">Note:</span> WordPress didn&#8217;t like me using so much code in this posts &#8212; I&#8217;ve tried to clean up where it got deleted, but the XML isn&#8217;t playing nice.  Just go to <a href="http://del.icio.us/rss/matthewvb">del.icio.us/rss/matthewvb</a> to get an example of the XML.</p>
<p><em>Update: 1.2.07:</em> I noticed this post wasn&#8217;t allowing for any future posts to go thru. I deleted the XML sample from this post, but you can still see an example at the link above. Sorry. Just ask with questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2006/12/20/delicious-on-rails-and-other-xml-feeds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>flickr in ruby on rails</title>
		<link>http://www.matthewvb.me/2006/10/18/flickr-in-ruby-on-rails/</link>
		<comments>http://www.matthewvb.me/2006/10/18/flickr-in-ruby-on-rails/#comments</comments>
		<pubDate>Wed, 18 Oct 2006 18:03:24 +0000</pubDate>
		<dc:creator>matthewvb</dc:creator>
				<category><![CDATA[ruby tutorials]]></category>

		<guid isPermaLink="false">http://www.matthewvb.com/?p=6</guid>
		<description><![CDATA[<p>wow &#8211; this could be the most frustrating thing to figure out.  it may have been cause i was just having a long day, but let me share the two best resources to get a <em>functioning</em> <a href="http://www.rubyonrails.org">ruby on rails</a> version of a <a href="http://www.flickr.com">flickr</a> pull.</p>
<p>In efforts to share some wisdom on what really needs to happen, check out the following:</p>
<p>The <a href="http://rubyonrails.org/screencasts">ROR Screencast</a> really will get something functioning, but it leaves out the following information about obtaining a valid API key.</p>
<p><strong>Register for a Flickr API</strong></p>
<p>Register for a <a href="http://www.flickr.com/services/api/">Flickr API</a>. Be sure to put non-commerical use. The key generated is the important thing.</p>
<p><strong>Install Flickr Gem</strong></p>
<p>In your rails app install the flickr gem:</p>
<p><code>gem install flickr</code></p>
<p>Then go in and edit the &#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>wow &#8211; this could be the most frustrating thing to figure out.  it may have been cause i was just having a long day, but let me share the two best resources to get a <em>functioning</em> <a href="http://www.rubyonrails.org">ruby on rails</a> version of a <a href="http://www.flickr.com">flickr</a> pull.</p>
<p>In efforts to share some wisdom on what really needs to happen, check out the following:</p>
<p>The <a href="http://rubyonrails.org/screencasts">ROR Screencast</a> really will get something functioning, but it leaves out the following information about obtaining a valid API key.</p>
<p><strong>Register for a Flickr API</strong></p>
<p>Register for a <a href="http://www.flickr.com/services/api/">Flickr API</a>. Be sure to put non-commerical use. The key generated is the important thing.</p>
<p><strong>Install Flickr Gem</strong></p>
<p>In your rails app install the flickr gem:</p>
<p><code>gem install flickr</code></p>
<p>Then go in and edit the flickr gem and scroll down and change the API key provided in the gem. Insert you&#8217;re newly obtained API Key.</p>
<p><strong>Initialize your API</strong></p>
<p>The final thing to do is get your API functioning. Check out <a href="http://www.maxdunn.com/RoR+and+Flickr">Generating a Flickr Token</a> near the bottom of this page. That will get things finalized.<br />
<strong>Code</strong></p>
<p>Go back to the <a href="http://rubyonrails.org/screencasts">ROR Screencast</a> on Flickr and follow along. Things should work for you now.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewvb.me/2006/10/18/flickr-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.matthewvb.me @ 2012-02-06 13:08:51 -->
