My goal with the RailsApps project is to provide stable example applications, first as starter applications for experienced developers, and second to help students and newcomers learn Rails.
A year ago, Twitter Bootstrap seemed an obvious choice as a front-end framework for the example applications. It is popular, and judging from the Big Badass List of Useful Twitter Bootstrap Resources, it has huge third-party support.
On August 19, 2013, Twitter Bootstrap 3.0 replaced Twitter Bootstrap 2.3 with major changes. Unfortunately, using Bootstrap with Sass and Rails means relying on 3rd party gems which have been slow to update for Bootstrap 3.0, since Bootstrap uses LESS as a CSS preprocessor and doesn’t support Rails or Sass (the Rails CSS preprocssor) directly.
Compounding the problem, I recommend and use SimpleForm for form helpers with the RailsApps example applications. SimpleForm supports Twitter Bootstrap 2.3 very nicely. But the changes in Twitter Bootstrap 3.0 introduced incompatibilities with SimpleForm. For several months I’ve been hoping to see the issues resolved but so far, it is a work in progress (for good reason; Rafael França is very busy as a member of the Rails core team).
Earlier this year, I released an in-depth tutorial and example application for Twitter Bootstrap 2.3. I’ve been repeatedly asked to update it for Twitter Bootstrap 3.0. I’ll do so when the SimpleForm issue is resolved.
There’s a more important issue, though. What do I recommend to Rails beginners? For the last six months, I’ve been writing Learn Ruby on Rails, a book for Rails beginners. It’s a solid book, covering Rails 4.0 and introducing professional practices. The book provides newcomers with everything they need to use the more advanced RailsApps tutorials. Until this week, it was based on Twitter Bootstrap 2.3.
Today I’ve released a new version of the book that introduces Zurb Foundation 4.0 instead of Twitter Bootstrap. For the book, Foundation is a better choice. Foundation uses Sass as a CSS pre-processor, as does Rails. Zurb supports Rails directly with a gem; using Twitter Bootstrap with Sass means relying on third-party gems. Though Twitter Bootstrap 2.3 is very popular among Rails developers, I’ve seen a trend of Rails developers choosing Foundation. Consequently, I feel I am in good company in recommending Foundation to students.
Going forward, for the RailsApps example applications, I will support a choice of either Zurb Foundation or Twitter Bootstrap. I’ve just released the RailsLayout gem which generates a default application layout plus partials for flash messages and navigation for either simple CSS, Zurb Foundation 4, or Twitter Bootstrap 3. The RailsLayout gem integrates with the Rails Composer to produce starter apps using either Zurb Foundation or Twitter Bootstrap.
I’ve had tremendous support from the Rails community both for the book (especially the Kickstarter campaign) and the RailsApps project. Supporting two front-end frameworks will make it more difficult to allocate the project’s limited resources (my time). Picking a stack is a difficult decision. I hope I’ve made the right choice.
It’s out! The first Rails 4.0 application from the RailsApps project.
It’s the Rails Bootstrap project.
Here’s everything you get:
The Rails Bootstrap application and tutorial is the first of a new series for Rails 4.0. With support from the RailsApps Tutorial subscribers, I’m going deeper and broader in coverage of Rails. There’s much more to come, but the Rails Bootstrap project is the first, going deeper into Rails and Twitter Bootstrap than previous material.
For the starter app, I’ve responded to feedback that not every app needs Devise or CanCan so this starter app sets up a basic Rails app with Twitter Bootstrap for those who don’t need the extras.
Starter app features include:
The tutorial goes beyond the starter app to demonstrate Twitter Bootstrap with additional features, including:
If the feedback is positive, I’ll adopt this format for forthcoming tutorials, showing how to deploy a starter app and then demonstrating additional features.
I’m happy to report the issue is resolved. I’ve released Rails Apps Composer 2.4.0. There is a lot of work to do to update the example applications and tutorials for Rails 4.0 but we’re moving forward.
A big thanks to André Arko @indirect for stepping forward with expert advice.
We’re expecting Rails 4.0 final to be released as soon as next week. There is a quite a lot of work to do to convert the RailsApps example applications to Rails 4.0, as well as updating the tutorials that accompany each one. One key element is the Rails Apps Composer gem which I use as a tool to create the RailsApps example applications. Unfortunately, I’ve hit a major showstopper obstacle.
It seems any application template created by the Rails Apps Composer gem cannot generate an application when used with Rails 4.0.0.rc2. This includes the extremely popular Rails Composer tool, which is an application template generated by the Rails Apps Composer gem.
Developers use the “rails new” command with an application template such as Rails Composer. That means Rails has to be installed and running, with its own set of gems active. If the application template installs a gem, it will run “bundle install.” Unfortunately, if a different version of a gem already is active, the application template crashes when trying to run “bundle install.”
In the past, I’ve said to resolve gem version conflicts by uninstalling the older gem version and installing the newest gem version and running “rails new” again. That usually works.
But now there’s a conflict between the minitest gem version 4.3.2 and a newer version of minitest. I don’t know where the newer version of minitest is required, but every time the application template runs, it crashes due to a conflict between minitest versions. And minitest is a Ruby default gem, which means version 4.3.2 cannot be uninstalled (it comes with Ruby 2.0.0-p195) to clear the way to only allow a newer version.
I’ve opened issue #220 Fails with Rails 4.0.0.rc2 due to minitest version conflict to discuss this.
Today I’ve released a new version of the Rails Apps Composer gem.
I use the Rails Apps Composer gem as a tool to create the RailsApps example applications. And many developers use it to create application templates for their own starter apps. Today there are two significant improvements:
The Gemfile created by the application template now meets expectations for clarity and readability. Gems are added programmatically to the Gemfile and until now, I had to specify groups such as “development” or “test” inline, which created clutter and didn’t conform to the formatting style most people use for a Gemfile. Though it was ugly, I didn’t have sufficient rubyfu to clean things up and organize groups in an eye-pleasing block style. Fortunately, an anonymous open source contributor named R2dR appeared from nowhere and contributed a seriously wicked Ruby module that tidies up the Gemfile. I don’t who you are, R2dR, but thank you! Dozens of developers complained about the ugly Gemfile but you stepped forward with the mad skillz to fix it.
In recent months several developers suggested I drop the gem version numbers from the Gemfile. There was a healthy discussion, Why specify gem version numbers in the Gemfile?, and I’m now convinced that gem version numbers aren’t needed in the generated Gemfile. So they’re gone.
Finally, I’d like to mention Mark D. Blackwell is a very active contributor to the Rails Apps Composer gem and he’s made many useful suggestions. I’m happy to include Mark’s pull request adding source signposts to generated templates which will make it easier for developers to dig through application templates generated by Rails Apps Composer.
I’ve just added the Startup Prelaunch Site tutorial to the collection of RailsApps Tutorials.
Most startups need a site to announce the founders’ plans and encourage visitors to enter an email address for notification of the site’s launch. The tutorial will show you how to:
Some startups use a service such as LaunchRock, KickoffLabs, or Unbounce to create a sign-up page but you might prefer to “own the code” that you can customize. This project aims to:
The tutorial shows how to use Devise to create user accounts that are not confirmed until an invitation is sent. Unlike a hosted page like LaunchRock, when your visitors sign up, they are creating real user accounts in a user database you can use after you launch. The tutorial explains how you can use git to create a branch for your sign-up application, deploy to Heroku, and continuing developing your “real” application to deploy when you are ready to launch. You’ll use the same database for users before and after launch.
I built the example application last year and released a preliminary tutorial. I was able to rewrite and extend the original tutorial, plus pay for user testing, because of financial support generated by subscriptions to the RailsApps Tutorials. So thank you subscribers!
Here’s the question. The mission of the RailsApps project is to make it easier for people to develop Rails applications. What could a Summer Coder do to advance the mission? Here are some of my ideas. What else would be worthwhile?
I have my own ideas but I’d like to crowdsource this. Please give me your suggestions, either as comments or via Twitter to @rails_apps.
Organizations such as Rails Girls and RailsBridge help newcomers get started who are not typical techies (white or Asian males). I’ve been enjoying teaching students at these workshops. The new developers are ambitious and enthusiastic. And it helps me to improve the RailsApps example applications and tutorials when I see the challenges encountered by learners who are new to Rails.
Rails Girls just announced a new program that takes their mission to a new level. It’s the Rails Girls Summer of Code and like Google Summer of Code, it aims to provide a stipend (tentatively $1500/mo) for students to work on open source projects. Unlike Google Summer of Code, Rails Girls doesn’t require applicants to be enrolled in a college. The program is open to any women who have participated in a RailsGirls or RailsBridge or similar workshop and are getting started with Ruby/Rails as newcomers.
Yesterday they began asking open source projects to apply to be matched with students. I jumped at the opportunity. Here’s my proposal:
The RailsApps project provides open source Rails example applications that help learners to close the gap between Ruby on Rails introductions for beginners and the piecemeal advice found on experts’ blogs. The example applications are popular, both among learners and intermediate-level developers who use the example applications as starter apps. There are eight example applications, all written for Rails 3.2, covering topics such as integrating authentication (Devise), authorization (CanCan), testing (RSpec and Cucumber), NoSQL (Mongoid), payments (Stripe), and subdomains.
In addition to benefiting the student directly with skill development and achievement, working on the RailsApps project will directly benefit other students by providing high quality Rails example code for study and the community at large by providing well-maintained starter applications. Just as important, the student will make a significant contribution to the RailsApps project by providing the perspective of a beginner to improve the example code and documentation.
I talked to Sven Fuchs, one of the Rails Girls organizers, about my proposal and he was encouraging. He asked me to provide more specifics about what a Summer Coder could do. So now I’m asking for ideas from supporters of the RailsApps project. Can I get your suggestions? How could a Summer Coder contribute to the RailsApps project? Submit comments or suggest via Twitter to @rails_apps.
Paavo Leinonen frequently uses the rails_apps_composer gem when building applications for clients. He recently contributed support for continuous testing with Guard.
I wanted to ask him why Guard is important. Paavo has been very enthusiastic about Rails Apps Composer so we created this interview. I swear a public relations firm didn’t edit this, it’s just Paavo’s natural enthusiasm that comes across here.
Why do you use Rails Apps Composer?
I work for Protoverstas in Finland which provides an agile three-week program to launch application ideas. Rails Apps Composer is an invaluable tool when prototyping and pivoting applications at a fast pace for demanding clients. It would be way too tedious to always start with “rails new” without any template. So Rails Apps Composer means less typing work for us and faster profits for our clients!
Tell us what’s on your desktop.
I do full-stack test-driven Rails development on OS X. I like to keep my environment as minimal and esthetically pleasing as possible. On my main monitor I keep two windows open side by side: MacVim as my text editor (using the Janus distribution with its amazing plugins) and iTerm2 as the terminal (running automated tests with Guard in one tab and using the zsh command line in another tab). I use the Solarized color theme in both, so they are easy on my eyes.
What is your Rails stack?
I’m very opinionated as a developer. I prefer PostgreSQL or MongoDB for most projects. I couldn’t imagine writing plain HTML again, so HAML is a necessity for me, as well as Coffeescript and LESS. Fixtures feel way too old-school, so the Fabrication gem is my choice. So is all the manual work needed for default forms, so please, SimpleForm for me. I like to deploy to Unicorn (and of course use it for development, too). These more or less permanent preferences are included in my Defaults file as described in Rails Apps Composer documentation.
What else do you need in a starter application?
Twitter Bootstrap is handy in some cases, though sometimes it’s best just to normalize CSS. Most apps I write require some kind of user management, so it’s cool that Devise and Omniauth provide most of the boring stuff right out of the box! Their routes and basic views are set up when using Rails Apps Composer, just how I like it.
What about testing?
I really want to encourage more developers to make test-driven development part of their practice. For unit testing I use RSpec and request testing I do with RSpec and Capybara. In my opinion Cucumber doesn’t provide that much value itself and in many cases acts only as a proxy to Capybara’s functionalities. In an ideal world, testing controllers, views, helpers, and routes all as single entities would be nice, but in the real world… just not worth it. Thoughtfully designed and well-written unit tests and request tests can make your test coverage rock solid.
How does Guard fit in?
When I edit and save any file in my Rails project, Guard keeps track of tests that are affected and runs them automatically. I see results immediately in my terminal window without needing to touch anything! It’s easy to keep track of which tests are passing already and which still need some more work.
On my second monitor I keep a browser open. Luckily I don’t need to touch it much, because automated tests do the boring and repetitious clicking work for me! Even when I need to touch it, I can do it without using the mouse, thanks to the Vrome plugin providing Vim-like controls for Chrome. Guard also restarts the Rails development server when needed, and monitors the Gemfile (automatically running “bundle install” as needed).
Keeping the development process streamlined and my environment beautiful helps me focus and keeps my quality standards high. Writing ugly code, copy-pasting or leaving features untested would feel just plain wrong. The right tools are important. So thanks, Daniel, for making my daily work more pleasurable with Rails Apps Composer!
Thanks, Paavo, for letting me know how it serves you, and for taking time to describe your work environment. And especially, thanks for contributing the Guard option to Rails Apps Composer.
I use RVM, the Ruby Version Manager, because I often switch between projects that require different versions of Rails. I create an RVM gemset for each project.
RVM looks for a .rvmrc file in a project root directory and automatically switches to the required version of Ruby and the correct gemset. Now, with version 1.19, RVM looks for files named .ruby-version and .ruby-gemset in the root directory. RVM will prompt you to replace the .rvmrc file with the two new files. It’s a worthwhile change, for several reasons. Unlike the .rvmrc file, the two new files contain no shell commands so they don’t need “trusting” and performance is faster. The .ruby-version file is also recognized by other Ruby version switchers such as chruby or rbenv (though the .ruby-gemset file is unique to RVM). I’m delighted to see movement toward a unified standard. A big thanks to Fletcher Nichol (fnichol) for initiating the unification effort.
The Rails Composer tool and the rails_apps_composer gem now create the .ruby-version and .ruby-gemset files when you generate a starter application. I’m upgrading the RailsApps example applications as well.
Here’s details for users making the transition to the new files. If you have a simple .rvmrc file:
rvm use ruby-2.0.0@myapp
It can be transformed to .ruby-version:
Be sure to remove the .rvmrc file as it takes precedence over any other project configuration files:
Keep in mind that if you’ve extended your .rvmrc file with custom shell commands you won’t be able to replace it. No worries though, as RVM will continue to recognize the .rvmrc file.
For details on how RVM gets configured per project, see a discussion.
Now is a good time to say thank you to Michal Papis (@mpapis) for his efforts to improve RVM. As a utility, RVM is not an official part of Rails but it greatly improves the day-to-day developer experience.
This week brought a great leap forward for Rails development with the release of Ruby 2.0.0 (final) and Rails 4.0.0 (beta).
Ruby 2.0 makes Rails much faster. You’ll love the speed improvement.
Rails 4 brings new features with new twists on implementing Rails applications. Rails 4 final is a few months away but you can install Rails 4.0.0.beta1 now to get familiar with the changes coming in Rails 4.
For projects in production, or deploying to production in the next few months, upgrade your applications to Rails 3.2.13 which patches Rails to fully support Ruby 2.0.0.
I’ve written two articles to help you get started with Ruby 2.0 and Rails 4.0.
The first article details how to install Ruby 2.0 with two different versions of Rails so you can easily switch between versions to work on production applications or begin work on new applications with Rails 4.0.
In the second article, I suggest a process to follow in updating Rails applications.
I’ve updated all the RailsApps example applications in the RailsApps GitHub repository to use Rails 3.2.13.rc1 and they all run nicely with Ruby 2.0. The Ruby 2.0 speed improvement is sweet, especially when a Rails application initially launches.
If you like to generate starter applications for Ruby 2.0 and Rails 3.2, you can use the Rails Composer tool. If you’ve installed Ruby 2.0 and Rails 3.2.13.rc1, the Rails Composer application template will build any of the example applications as a Rails 3.2.13 application.
I’ll add a new suite of Rails 4.0 example applications and tutorials to the RailsApps project before Rails 4.0 final is released.
I released version 2.2.32 of the Rails Apps Composer gem today.
Haml version 4.0 was released yesterday with a new implementation of the html2haml utility. The Rails Apps Composer gem uses the html2haml tool to convert ERB files to Haml files. That means you can use the Rails Composer tool to create a Haml version for any our example applications.
I like to use Haml for my own projects because it reduces the clutter in my Rails view templates. See the article Haml and Rails for a discussion of advantages and drawbacks.
I’m intrigued by Slim (an ERB or Haml alternative) because I’ve heard it is fast and even less cluttered than Haml. I found a haml2slim gem to convert Haml templates to Slim templates but it only serves as a preliminary tool for templates conversion. The Rails Composer tool offers an option of using Slim but marks it as “experimental” because most view files need to be manually tweaked before they will work.
I updated a few other gems for the release of version 2.2.32 of Rails Apps Composer (see the changelog).