<?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>AVNet Labs &#187; Rails</title>
	<atom:link href="http://avnetlabs.com/category/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://avnetlabs.com</link>
	<description>Accessible web development</description>
	<lastBuildDate>Mon, 04 Jan 2010 21:28:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails makes you think you can</title>
		<link>http://avnetlabs.com/rails/rails-makes-you-think-you-can</link>
		<comments>http://avnetlabs.com/rails/rails-makes-you-think-you-can#comments</comments>
		<pubDate>Tue, 21 Apr 2009 05:12:24 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/rails-makes-you-think-you-can</guid>
		<description><![CDATA[I spent a couple of hours last weekend going over a Rails app I wrote almost two years ago. It was the very first Rails application I had written (apart from the follow-the-screencast throwaway ones) and I couldn&#8217;t help cringing when I saw the code I got paid good money to write.
That app is still [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a couple of hours last weekend going over a Rails app I wrote almost two years ago. It was the very first Rails application I had written (apart from the follow-the-screencast throwaway ones) and I couldn&#8217;t help cringing when I saw the code I got paid good money to write.</p>
<p>That app is still my most ambitious project ever and I&#8217;m still shocked I decided to do it in Ruby (a language I barely knew) and Rails (after playing with it for a few weeks) when I had a couple of years experience in PHP and some production apps already running on CodeIgniter. I guess it was the hype.<br />
However, almost two years later and the app is still running smoothly (I had to tweak it a bit over the weekend). I am still not sure I would have taken on the project &#8211;  an internal stock trading app with a social angle to it (I was freelancing then and working alone) if I had to do it PHP but in retrospect it would probably have been done better in PHP. I&#8217;d have had less fun though.
</p>
<p>
Rails is so deceptively simple it makes you feel you&#8217;re a superstar programmer even when you just have a couple of lines of code under your belt. However, after working with it for a while, you start to appreciate how complex it is to get things done when they don&#8217;t fall into the Ruby on Rails sweet spot. I wouldn&#8217;t have it any other way though. When it rocks, it really rocks.
</p>
<p>I currently use PHP (and the Zend Framework) at work and I have come to appreciate the flexibility of ZF but I wouldn&#8217;t recommend the framework for programming beginners. Using a lot of the components requires a good grasp of programming concepts and compared to Rails where components are written for specific use cases, with ZF,  you have to come up with yours. I am currently still trying to figure out where I can use Zend_Navigation in the recently released version of ZF. I know it will come in useful but I just have to tweak and flesh it out to make it work for me and that pretty much sums up the ZF-Rails differences quite well. One makes you think you can without even trying while with the other, you know you can but you&#8217;ll just have to work at it.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/rails-makes-you-think-you-can/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Finally&#8230; passenger for nginx</title>
		<link>http://avnetlabs.com/rails/finally-passenger-for-nginx</link>
		<comments>http://avnetlabs.com/rails/finally-passenger-for-nginx#comments</comments>
		<pubDate>Fri, 17 Apr 2009 08:23:04 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/finally-passenger-for-nginx</guid>
		<description><![CDATA[I just spent last weekend setting up a new slice at SliceHost (my bestest host ever) for a couple of Rails apps only to read this post announcing the release of Phusion Passenger for Nginx.

Considering I only needed the slice for Rails (No php and the DB is on another slice), I could have gone [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent last weekend setting up a new slice at <a href="http://www.slicehost.com/">SliceHost</a> (my bestest host ever) for a couple of Rails apps only to read <a href="http://blog.phusion.nl/2009/04/16/phusions-one-year-anniversary-gift-phusion-passenger-220/">this post</a> announcing the release of Phusion Passenger for Nginx.</p>
<p>
Considering I only needed the slice for Rails (No php and the DB is on another slice), I could have gone with Nginx except that I&#8217;ve been spoilt by Passenger&#8217;s upload-and-go deployment and being able to squeeze more apps into  a small VPS (the inactive ones shut down and release memory). Now hopefully, it&#8217;s the best of both worlds.
</p>
<p>
I&#8217;ll still have to learn Nginx quirks considering I&#8217;ve always used Apache but the promise of faster page serving and a lower memory footprint is motivation enough.
</p>
<p>
Kudos to the  guys at <a href="http://www.phusion.nl">Phusion</a> for their awesome products (I also use <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise</a>). Congrats on your anniversary and a lot more power to your elbow!
</p>
<p>
On a related note, I learnt the hard way that Rails 2.3 and an old version of Passenger don&#8217;t mix very well.<br />
Even after updating the passenger gem I couldn&#8217;t get Rails to load. The solution is to re-install the passenger module (passenger-install-apache2-module) and update your apache config file. Hope that helps someone as I spent a bit too long trying to fix it.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/finally-passenger-for-nginx/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Restful authentication with Rails 2: Usage</title>
		<link>http://avnetlabs.com/rails/restful-authentication-with-rails-2-usage</link>
		<comments>http://avnetlabs.com/rails/restful-authentication-with-rails-2-usage#comments</comments>
		<pubDate>Sun, 18 Jan 2009 10:05:21 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/restful-authentication-with-rails-2-usage</guid>
		<description><![CDATA[This blog has been inactive for ages and one of my 2009 resolutions is to show the poor thing some love! I will try to keep it even if it&#8217;s the only resolution I don&#8217;t give up on. Things have become a bit less hectic at work (or maybe I&#8217;ve just gotten used to the [...]]]></description>
			<content:encoded><![CDATA[<p>This blog has been inactive for ages and one of my 2009 resolutions is to show the poor thing some love! I will try to keep it even if it&#8217;s the only resolution I don&#8217;t give up on. Things have become a bit less hectic at work (or maybe I&#8217;ve just gotten used to the system) and the spirit is willing so hopefully &#8230;</p>
<p>In my post detailing the <a href="http://www.avnetlabs.com/rails/restful-authentication-with-rails-2">installation of the Restful authentication plugin</a>, it was pointed out to me in the comments that I didn&#8217;t show the actual usage of the plugin. My bad! This post will amend that oversight.</p>
<p>As an aside, while my tutorial post is still very relevant, I don&#8217;t do the installation from scratch anymore. In <a href="http://www.avnetlabs.com/rails/jump-start-your-next-rails-2-application">one of my earlier posts</a>, I mentioned <a href="http://jimneath.org/2008/09/09/bort-base-rails-application/">Bort</a> and I still recommend it as a way of speeding up the initial setup of your rails project. However, the usage is the same whether you do the installation manually or use Bort.<br />
Another Rails starter app I have used is <a href="http://github.com/leethal">leethal&#8217;s</a> <a href="http://github.com/leethal/blank-rails-app/tree/master">blank-rails-app</a>. This is as light as they come and I use this when I do smaller sites in Rails rather than full fledged apps.</p>
<p>One of the advantages of installing manually is that Bort defaults to using RSpec as the test framework (at least on my system).<br />
A manual installation checks for the presence of the spec folder and if it doesn&#8217;t exist, it creates the default Test::Unit tests.<br />
However, Rails creates both a spec and test folder when i create a new Rails project (presumably because I&#8217;ve got the rspec gem installed ) and so to use Test::Unit I have to delete the spec folder before running the plugin&#8217;s generator.</p>
<p>To use the Restful Authentication plugin in your Rails app:</p>
<ul>
<li style="padding-bottom: 10px;"> <strong>Include AuthenticatedSystem</strong><br />
The generated controllers include the AuthenticatedSystem module but we need this available to all controllers.<br />
Delete the &#8216;include AuthenticatedSystem&#8217; line from the Sessions and Users controllers and move the line to the application controller.<br />
The AuthenticatedSystem module (located in lib/authenticated_system.rb) contains the core methods used in our application code for authentication.</li>
<li> <strong>Add a before filter in the controllers you want to protect</strong><br />
For any controller with actions that need protecting, add a before filter to the controller.</p>
<pre class="brush: ruby;">
class PageController &lt; ApplicationController
# protect all actions in this controller
before_filter :login_required
...
</pre>
<pre class="brush: ruby;">
class PageController &lt; ApplicationController
# protect all actions in this controller except the index action
before_filter :login_required, :except =&gt; :index
...
</pre>
<pre class="brush: ruby;">
class PageController &lt; ApplicationController
# protect all actions in this controller except the index and contact actions
before_filter :login_required, :except =&gt; [:index, :contact]
...
</pre>
<pre class="brush: ruby;">
class PageController &lt; ApplicationController
# protect only the support action
before_filter :login_required, <img src='http://avnetlabs.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly =&gt; :support
...
</pre>
<p>For the protected actions, the user is redirected to the new session url. We&#8217;ve already added a named route called &#8216;login&#8217; to the routes.rb file pointing to this same action and I&#8217;d rather have my urls end with &#8216;/login&#8217; than &#8216;/sessions/new&#8217;.<br />
To do that I override the access_denied method in the application_controller.rb.</p>
<pre class="brush: ruby;">
class ApplicationController &lt; ActionController::Base
helper :all # include all helpers, all the time

include AuthenticatedSystem

def access_denied
alias new_session_path login_path
super
end
...
</pre>
</li>
<li> <strong>Use the plugin methods in your controller</strong>
<pre class="brush: ruby;">
def index
if logged_in?
@profile = current_user.profile
# or
# @profile = Profile.find(current_user)
end
end
</pre>
</li>
<li> <strong>Use the plugin methods in your view</strong>
<pre class="brush: ruby;">

&lt;% if logged_in? %&gt;
Welcome &lt;%= current_user.login %&gt;
Your Profile: &lt;%= @profile.description %&gt;
&lt;% end %&gt;
</pre>
</li>
</ul>
<p>And that&#8217;s all there is to it. Now get building!</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/restful-authentication-with-rails-2-usage/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Jump start your next Rails 2 application</title>
		<link>http://avnetlabs.com/rails/jump-start-your-next-rails-2-application</link>
		<comments>http://avnetlabs.com/rails/jump-start-your-next-rails-2-application#comments</comments>
		<pubDate>Wed, 29 Oct 2008 18:17:39 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/jump-start-your-next-rails-2-application</guid>
		<description><![CDATA[Ruby on Rails has gotten really popular owing mostly to its well-earned reputation for rapid web application development. The plugin system has also helped to add loads of functionality not built into the core. It is almost certain you&#8217;ll find a plugin (or solution) to solve most problems you run into as long as it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails has gotten really popular owing mostly to its well-earned reputation for rapid web application development. The plugin system has also helped to add loads of functionality not built into the core. It is almost certain you&#8217;ll find a plugin (or solution) to solve most problems you run into as long as it&#8217;s not too obscure.</p>
<p>However you can do better than typing &#8216;rails PROJECT&#8217; to start a new rails app. I have used both <a href="http://jimneath.org/2008/09/09/bort-base-rails-application/">bort</a><strong> </strong>and <a href="http://portal.insoshi.com/">insoshi</a> as bases for my new rails application and I recommend them highly.</p>
<h3>Bort &#8211; A Base Rails Application</h3>
<p>Bort is a base Rails application with various commonly used plugins pre-installed. Various maintenance tasks have also been done (e.g.  the index.html file has been deleted, the views have been modified and the database has been set as the session store).</p>
<p>The package includes plugins I usually end up installing and saves me a couple of hours when I start a new Rails app. Pre-installed  plugins include Restful Authentication, Exception Notifier, Will Paginate and Asset Packager. I actually use <a href="http://github.com/MattHall/bort/tree/master">a fork</a> which is essentially the same but uses <del>usernames</del> <ins>email addresses</ins> for authentication with the Restful Authentication plugin rather than <del>email addresses</del> <ins>usernames</ins>.</p>
<p>The  downside when I started was the use of RSpec rather than Test::Unit but then it did force me to start using RSpec and I&#8217;m glad I did.</p>
<h3>Insoshi &#8211;  Social Networking Platform</h3>
<p>For a social site, Insoshi will save a lot of time. It is an open source social networking platform built on Rails and it rocks! Apart from being a complete application you can build from, it&#8217;s also got loads of pre-installed plugins which include Will Paginate, Restful Authentication and Attachment-fu.</p>
<p>Like Bort, it uses RSpec rather than Test::Unit. <a href="http://portal.insoshi.com/">Check it out</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/jump-start-your-next-rails-2-application/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Restful Authentication with rails 2</title>
		<link>http://avnetlabs.com/rails/restful-authentication-with-rails-2</link>
		<comments>http://avnetlabs.com/rails/restful-authentication-with-rails-2#comments</comments>
		<pubDate>Sat, 19 Jan 2008 13:11:59 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/restful-authentication-with-rails-2</guid>
		<description><![CDATA[I recently had to build an authentication system into a project and seeing as the restful authentication plugin was getting such buzz, I decided to try it out.
The problem was, most of the information I found on the internet was dated and I had to make a couple of changes to get it to work [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to build an authentication system into a project and seeing as the <a title="restful authentication plugin" href="http://agilewebdevelopment.com/plugins/restful_authentication">restful authentication plugin</a> was getting such buzz, I decided to try it out.</p>
<p>The problem was, most of the information I found on the internet was dated and I had to make a couple of changes to get it to work on Rails 2.0. <a href="http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated">This site</a> and <a href="http://www.railsforum.com/viewtopic.php?id=14216&amp;p=1">this forum post</a> were really helpful. This post documents the steps I took (or rather, the steps I&#8217;ll take next time I use it) to get the plugin working. It assumes you already have a rails application running and want to add authentication to it.</p>
<ul>
<li class="tutorial-section"><strong>Install the plug-in<br />
</strong>Open up a console window and navigate to the root of your application.<br />
Use script/plugin to install the plugin.</p>
<pre class="brush: ruby;">ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/</pre>
</li>
<li class="tutorial-section"><strong> Run the generator<br />
</strong>The generator sets up your controllers, model, views and observer as well as modify the routes.rb file (sets up session and users as resources). The session controller is used for signing in and out of the system while the user controller takes care of the rest.If you <strong>do not</strong> need a user activation system built into the system, type the line below:</p>
<pre class="brush: ruby;">ruby script/generate authenticated user sessions</pre>
<p>If you need a user account activation system, use the line below. The rest of this post will assume the system includes user activation (the system is a lot simpler without user activation enabled).</p>
<pre class="brush: ruby;">ruby script/generate authenticated user sessions --include-activation</pre>
</li>
<li class="tutorial-section"> <strong>Run the migration</strong><br />
The system also generated a migration file. Run the migration with:</p>
<pre class="brush: ruby;">rake db:migrate</pre>
</li>
<li class="tutorial-section"> <strong>Modify the routes file</strong><br />
Open up config/routes.rb and add to the named route section:</p>
<pre class="brush: ruby;">
map.activate '/activate/:activation_code', :controller =&gt; 'users', :action =&gt; 'activate'
</pre>
<p>While the routes file is still open, add more named routes (giving the user actions nice, friendly urls)</p>
<pre class="brush: ruby;">
map.signup '/signup', :controller =&gt; 'users', :action =&gt; 'new'
map.login '/login', :controller =&gt; 'sessions', :action =&gt; 'new'
map.logout '/logout', :controller =&gt; 'sessions', :action =&gt; 'destroy'
</pre>
</li>
<li class="tutorial-section"><strong>Add an observer (required for user activation emails)</strong><br />
Add an observer to config/enviroment.rb (within the Rails::Initializer.run block) :</p>
<pre class="brush: ruby;">
config.active_record.observers = :user_observer
</pre>
<p>At this point, the basic system should be working. Start up your development server and go to http://localhost:3000/signup. You should see the sign up form.<br />
Also try http://localhost:3000/login to confirm it&#8217;s fine.</li>
<li class="tutorial-section"> <strong>Set up ActionMailer (required for user activation emails)</strong><br />
The rails config/environment.rb file includes a Rails::Initializer.run block and prior to Rails 2, configuration code went in there.<br />
With Rails 2, there&#8217;s now a directory (config/initializers) where seperate, discreet bits of configuration are placed in files of their own.<br />
These are automatically loaded after plugins are loaded when Rails starts up.Create a new file called mail.rb in the config/initializers directory (you can actually call the file anything you like). SMTP setting will go into this file.<br />
Rails 2 also changed the variable for ActionMailer settings from server_settings to smtp_settings<br />
Place the following into the mail.rb file:</p>
<pre class="brush: ruby;">
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
	:address =&gt; &quot;mail.example-domain.com&quot;,
	:port =&gt; 25,
	:domain =&gt; &quot;www.example-domain.com&quot;,
	:authentication =&gt; :login,
	:user_name =&gt; &quot;user@example-domain.com&quot;,
	:password =&gt; &quot;secret&quot;
}
</pre>
<p><strong>:address and :port</strong> &#8211; Determines the address and port of the SMTP server you&#8217;ll be using. These default to localhost and 25 , respectively.<br />
<strong>:domain</strong> &#8211; The domain the mailer should use when identifying itself to the server (usually the top-level domain name of the machine sending the email).<br />
<strong>:authentication</strong> &#8211; One of :plain, :login or :cram_md5. Should be omitted if the server does not require authentication. Also omit :username and :password options if you omit this parameter.<br />
<strong>:username and :password</strong> &#8211; Mail account login credentials. Required if :authentication is set.</li>
<li class="tutorial-section"><strong>Modify the activation email parameters</strong><br />
Open the production and development configuration files, config/environments/production.rb and config/environments/development.rb respectively.In the development config file:</p>
<pre class="brush: ruby;">SITE_URL = &quot;localhost:3000&quot;</pre>
<p>and in the production:</p>
<pre class="brush: ruby;">SITE_URL = &quot;example-domain.com&quot;</pre>
<p>You need to restart the server for these settings to take effect.Open app/models/user_mailer.rb. Change:</p>
<pre class="brush: ruby;">@body[:url]  = &quot;http://YOURSITE/activate/#{user.activation_code}&quot;</pre>
<p>to:</p>
<pre class="brush: ruby;">@body[:url]  = &quot;http://#{SITE_URL}/activate/#{user.activation_code}&quot;</pre>
<p>Change:</p>
<pre class="brush: ruby;">@body[:url]  = &quot;http://YOURSITE/&quot;</pre>
<p>to:</p>
<pre class="brush: ruby;">@body[:url]  = &quot;http://#{SITE_URL}/&quot;</pre>
<p>Change the setup_email block settings (ADMINEMAIL and YOURSITE) to your desired settings.Open the email template files (app/views/user_mailer/activation.html.erb and app/views/user_mailer/signup_notification.html.erb) and modify as desired.</p>
<p>And that&#8217;s it. The system should now be working.</p>
<p><strong>Note:</strong> You need to include flash[:notice] and flash[:error] in your templates or layout to view the status messages e.g. just before the &lt;%= yield %&gt; line in app/views/application.html.erb, type:</p>
<pre class="brush: ruby;">
&lt;%= flash[:notice] %&gt;
&lt;%= flash[:alert] %&gt;
</pre>
</li>
</ul>
<p><strong>Update:</strong> Need help with using the plugin in your view or controller? <a href="http://www.avnetlabs.com/rails/restful-authentication-with-rails-2-usage">Go here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/restful-authentication-with-rails-2/feed</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Giving up on mongrel_cluster on windows</title>
		<link>http://avnetlabs.com/rails/giving-up-on-mongrel_cluster-on-windows</link>
		<comments>http://avnetlabs.com/rails/giving-up-on-mongrel_cluster-on-windows#comments</comments>
		<pubDate>Sun, 30 Dec 2007 19:47:07 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/rails/giving-up-on-mongrel_cluster-on-windows</guid>
		<description><![CDATA[That&#8217;s it! I&#8217;ve given up trying to deploy a Rails app with capistrano from windows.  Just spent two days trying to set this up (even tried cygwin)  with no luck.
The solution? VirtualBox. I have just gone from installing Ubuntu server in a virtual machine to deploying the application in thirty minutes. It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s it! I&#8217;ve given up trying to deploy a Rails app with capistrano from windows.  Just spent two days trying to set this up (even tried cygwin)  with no luck.</p>
<p>The solution? <a href="http://www.virtualbox.org/" title="VirtualBox">VirtualBox</a>. I have just gone from installing Ubuntu server in a virtual machine to deploying the application in thirty minutes. It&#8217;s a bit long-winded commiting to subversion from windows and changing to the virtual machine to use capistrano but it works so I&#8217;m happy.</p>
<p>Why am I still working in windows? I ask myself that all the time but I&#8217;ve got so much stuff installed and set up on my laptop the thought of changing is depressing. Also use Visual Studio Express once in a while and that only works on windows.</p>
<p>Two thumbs up for VirtualBox.</p>
<p>Update: Finally got Capistrano to work on windows. About time!</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/rails/giving-up-on-mongrel_cluster-on-windows/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.324 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 01:40:47 -->
