May 25, 2011
If you are looking for Rails example applications for Rails 3.1 you must take a look at the “Crazy Deep” Rails Example Apps hosted on GitHub. Each is accompanied by detailed Rails Tutorials and Rails application templates that can be used to generate a starter app. These example apps have become quite popular and there’s a lot of effort among Rails developers to keep the examples current.
Here’s a list of the available example apps:
February 27, 2010
FOR RAILS 3.0: See my Github repo for a complete example implementation of Rails 3 subdomains with authentication (including a detailed tutorial). It’s much easier to implement subdomains in Rails 3 than in Rails 2.3. Still there’s a few tricks to solve some common problems which you can see in the new example.
FOR RAILS 2.3:
I’ve released an open source application for Rails 2.3 that shows how to integrate subdomains with authentication.
User management and authentication is implemented using the Devise gem. The subdomain_routes gem implements subdomains and routing.
You can use this project as a starting point for any Rails web application that requires subdomains and authentication. You can easily customize the application for your own needs.
You can obtain the source code here:
A complete walkthrough tutorial is available on the GitHub wiki. The tutorial documents each step I followed to create the application:
View the Tutorial
This application implements a particular scenario where subdomains are required. There is a “main” domain where anyone can visit and create a user account. There is an “admin” subdomain for the exclusive use of administrators. And registered users can create any number of subdomains which could host blogs or other types of sites. This approach is familiar to users of sites such as wordpress.com and can be called “blog-style subdomains in Rails”.
August 13, 2008
FOR RAILS 3.0: A newer and more current Rails authentication example app shows how to set up Rails with the Devise authentication gem. It’s got a detailed Rails authentication tutorial plus an application template that can be used to generate a starter app. It shows how to use RSpec and Cucumber for testing with Devise as well. There’s a similar example app that shows how to set up Devise for authentication with the Mongoid gem and MongoDB database for quick development without schemas or migrations.
UPDATE: Rails has advanced since this application was released in mid-2008. As of February 2010, Rails is currently at version 2.3.5 (and Rails 3 is in beta). Several Rails gems are now available that provide a turnkey authentication solution, including Authlogic, Devise, and Clearance. You can also look at Technoweenie’s restful-authentication generator. The Ruby Toolbox page for Rails Authentication shows which are most popular. I personally recommend Devise.
I’ve released an open source Rails application that provides an example of RESTful Authentication.
It provides a complete system for managing users, including sign up and verification of a new user’s email address, login with role-based access control, and a system of resetting forgotten passwords, all using a RESTful architecture.
You can easily customize the application for your own needs.
You can obtain the source code here:
It is based on recommendations from the forum discussion Restful Authentication With All the Bells and Whistles.
April 28, 2008
If you are working on a branch and want to abandon it, what do you do?
It’s easy to remove it from your local repository:
$ git branch -d mybranch # delete branch "mybranch"
And then how do you remove it from a GitHub repository? This works:
$ git push firstname.lastname@example.org:<my_account>/<my_repository>.git :heads/<mybranch>
But there’s an easier way. Scott Chacon suggests:
You can also do (assuming ‘origin’ is the name of your remote):
git push origin :mybranch
Scott Chacon is the author of the Git Internals book from Peepcode.
April 25, 2008
Most web applications are built by teams of software developers and graphic designers. When software developers build their own sites, they tend to reuse designs they’ve used before or borrow from sites they like. Sometimes they’ll ask a graphic designer to create a few icons or propose a fresh look and feel. For their part, graphic designers tend to want to create the kind of eye-catching design that will win design awards for innovation and creativity. In my experience, most developers and designers are only dimly aware that there is a profession called “Interaction Design.” With any profession, there is a body of knowledge and expertise, and in Interaction Design, it’s all devoted to developing the optimal user experience. Most web applications need interaction design. At a minimum, developers and designers would do well to familiarize themselves with the accumulated body of knowledge from the interaction design field. And, if possible, get an interaction design expert on your team.
I’ve begun collecting favorite sources of information about interaction design:
and I’ll add to this list as I find more.
April 18, 2008
I’ve been looking for a Rails example app that demonstrates “best practice” development techniques and provides basic features, to be used as a “skeleton” starting point for development of a new project.
I’m primarily interested in finding an app that is written for Rails 2.0, that implements a RESTful architecture, and uses RSpec for specifications/testing. Optimally, it should implement authentication (using restful_authentication) and authorization, provide an interface for users to manage their accounts (or profiles), and provide a rudimentary administrative interface for adding or deleting users. I’ve looked at a number of open source apps (see the post Survey of Rails Example Applications).
There are three open source social network apps for Rails that come close to fulfilling my requirements. I’ll compare them here.
LovdbyLess is a social network platform from the development firm Less Everything. It is hosted on GitHub at stevenbristol/lovd-by-less. It is RESTful and uses Rails 2.0 but not RSpec or restful_authentication.
RailsCoders is the example app from the book Practical Rails Social Networking Sites, published by Apress. It’s a full-featured app and it is RESTful. The author chose to implement his own authentication (using RESTful principles) rather than using the restful_authentication plugin. The app was written for Rails 1.2.3, not Rails 2.0, but an upgrade is relatively easy. It has Test::Unit tests but not RSpec specifications/tests. As of April 11, 2008, it is hosted on GitHub at abradburne/railscoders, where the author has begun work on a new version of the app.
The authors Michael Hartl and Aurelius Prochazka built a social network app named RailsSpace for a book of the same name. RailsSpace doesn’t meet my minimal requirements (not Rails 2.0, not RESTful, no RSpec) but Michael Hartl is taking the lead in developing a new social network app named Insoshi, which improves on RailsSpace. It is hosted on GitHub and development has been funded by Y Combinator, a venture capital incubator. Insoshi is a Rails 2.0 app, full-featured and RESTful, uses restful_authentication and RSpec, and thus meets my requirements.
April 13, 2008
The most popular revision control system for an open source Rails app is Git.
I installed Git using MacPorts with
sudo port install git-core.
After installing Git, I installed the Git bundle for TextMate.
I signed up for Git hosting at GitHub. The process is nearly self-explanatory but I consulted two tutorials, A Tutorial Introduction to Git and Setting up a new Rails app with Git. I discovered I needed to create an ssh public/private key pair on my local machine and add the public key to my GitHub profile before I could push the app to the GitHub repository.
I’ve found two screencasts about using Git wih Rails, from PeepCode and Using Git to Manage and Deploy your Rails Apps from Scott Chacon.
GitHub has their own Git Guides but the best instructions I’ve found for using Git are the Git Guides from the Insoshi open source project.