ZURB's Foundation is a front-end for quickly building applications and prototypes. It is similar to Twitter Bootstrap but uses Sass instead of LESS. Here you will learn the basics of the grid sys...
With the release of Rails 4.0.0.rc1 it's time to try it out and report any bugs. Here I walk you through the steps to upgrade a Rails 3.2 application to Rails 4.
Rails commands, such as generators, migrations, and tests, have a tendency to be slow because they need to load the Rails app each time. Here I show three tools to make this faster: Zeus, Spring,...
The ActiveModel::Serializers gem can help you build JSON APIs through serializer objects. This provides a dedicated place to fully customize the JSON output.
Learn how to easily add a user activity feed using the public_activity gem. Here I show both the default setup using model callbacks and a manual way to trigger activities.
Here we take a look at two tools to aid us in development: Better Errors which makes it easier than ever to debug exceptions, and RailsPanel, a Chrome extension to see Rails requests.
Rails 4.0 is still unfinished, but it is shaping up to become a great release. Here I show how to setup a new Rails 4.0 (edge) application and walk through many of its new features.
Allow users to import records into the database by uploading a CSV or Excel document. Here I show how to use Roo to parse these files and present a solution for validations.
Instead of presenting a sign up form to the user, consider creating a temporary guest record so the user can try out the application without filling in their information up front. They can then b...
Turbolinks can make your Rails app feel faster by using JavaScript to replace the page content when clicking a link. It will be default in new Rails 4.0 applications, but here I show how to use i...
The cache_digests gem (also included in Rails 4) will automatically add a digest to the fragment cache key based on the template. If a template changes the cache will auto-expire. But watch out f...
RubyGems can make it easy to add a feature to a Rails application, but it can also cause headaches down the road. Here I give some tips on researching gems to decide which one to choose, or when ...
There are several gems to help implement tags in a Rails app. Here I show you how to integrate acts-as-taggable-on and then show how to do it from scratch.
FnordMetric allows you to chart events in real time. This is great for keeping track of user activity in your Rails app as demonstrated in this episode.
JRuby is a polished and stable Ruby implementation. Here I show the basics of setting it up and executing Java from within Ruby. I also see how it compares with MRI at running threads.
Learn how to do extensive image manipulation with the ImageMagick commands. Also learn how RMagick can be used in combination with CarrierWave to process uploaded images.
Bullet will notify you of database queries that can potentially be improved through eager loading or counter cache column. A variety of notification alerts are supported.
Ransack allows you to easily build complex search forms. It also helps in adding sortable links and building a dynamic advanced search page.
MiniProfiler allows you to see the speed of a request conveniently on the page. It also shows the SQL queries performed and allows you to profile a specific block of code.
Sidekiq allows you to move jobs into the background for asynchronous processing. It uses threads instead of forks so it is much more efficient with memory compared to Resque.
If you need to calculate an average user's rating or sum up a number of votes, consider using the activerecord-reputation-system gem. Here I will cover the basics and also briefly present a from-...
http://railscasts.com/episodes/364-active-record-reputation-system
As you will see it is easy to add a CSV export option to Rails. Here I also show how to export for Excel in a variety of formats.
This will show how to create a new facebook application and configure it. Then add some authentication with the omniauth-facebook gem and top it off with a client-side authentication using the Ja...
The Brakeman gem will scan the Ruby code of a Rails application and alert you to common security vulnerabilities.
If a user's authentication cookie is sent over an insecure connection it is vulnerable to session hijacking, or more specifically, sidejacking. Learn how this is done, and how you can prevent it.
http://railscasts.com/episodes/356-dangers-of-session-hijacking
Squeel provides a comprehensive DSL for writing SQL queries in Ruby. It is built upon Arel giving you access to many of its powerful features.
There are many approaches to locking down an API. Here I start off with HTTP Basic authentication then move on to generating a unique token which can be passed through a URL parameter or HTTP hea...
APIs should be consistent, but it is difficult to do this when returning a JSON response along side the HTML interface. Here I show how to add a versioned, RESTful API. The version can be determi...
It is often asked: Is Rails a good fit if I only need to serve an API? In this episode I show how to use the Rails API gem to create a slimmer Rails application designed to respond with JSON.
Creating a wizard form can be tricky in Rails. Learn how Wicked can help by turning a controller into a series of multiple steps.
Deploying to Amazon EC2 allows you to scale an application quickly. Learn how to use Rubber to deploy to the cloud with just a few commands and monitor the cluster with various web tools.
PostgreSQL can act as a worker queue which can replace the need for a separate process to manage the background jobs. Here you will learn how to do this with the queue_classic gem.
Postgres is a feature-packed relational database that every Rails developer should consider using. Here you will learn how to install it, add it to a new application, and transition from an exist...
DataTables makes it easy to convert a plain HTML table into one with pagination, sorting, and searching - all done with JavaScript and jQuery. Here I show how to set this up and use a Rails appli...
Rails has great internationalization (I18n) support making it easy to translate static text into other languages, but how do we translate database content? Learn how using Globalize 3 in this epi...
Copycopter provides a nice interface that clients can use to edit the text in a Rails application. Learn how to deploy a Copycopter server using Heroku and integrate it in a Rails application thr...
Compass improves the Sass experience by providing useful mixins, functions, and more. You will also learn how to make CSS sprites with it in this episode.
If you need to quickly create an informational site that can be easily edited, consider using a content management system. Here I show how to build a site using Refinery CMS.
If you are tired of the browser vendor prefixes in CSS, check out Bourbon. It provides Sass mixins and functions to make CSS more convenient.
Twitter Bootstrap can help make beautiful web apps quickly by providing you with useful CSS and JavaScript. Here you will learn how to include it into Rails with the twitter-bootstrap-rails gem.
ActiveAttr provides what Active Model left out. If you need to create a table-less model with features similar to Active Record, watch this episode.
There are a variety of ways to pass variables from a Rails application to JavaScript. Here I show three techniques: a script tag, a data attribute, and the Gon gem.
http://railscasts.com/episodes/324-passing-data-to-javascript
RABL - Ruby API Builder Language - provides a DSL for generating JSON or XML responses in a Ruby application. Learn how to share and configure complex JSON data in this episode.
Jbuilder provides a DSL for generating JSON. It includes a template engine which allows you to create complex responses with helpers and conditions.
Rails 3.2 sports many new features including automatic explain queries, tagged logging, key-value store in Active Record, improved migration generator and more. Learn all about these new features...
Private Pub makes it easier than ever to publish and subscribe to real-time events in a Rails app. You can use publish_to with a block of JavaScript or supply a hash for use with JSON.
If you are tired of model ids in the URL, overriding to_param can only get you so far. The friendly_id plugin can help by making it easy to generate a URL slug and maintain a history.
http://railscasts.com/episodes/314-pretty-urls-with-friendlyid
HTML email can be difficult to code because any CSS should be made inline. Here I present a few tools for doing this including the premailer-rails3 and roadie gems.
Learning Ruby on Rails can be overwhelming, especially if you are new to programming. Here I will take you on a tour through various resources to help get started with Rails.
http://railscasts.com/episodes/310-getting-started-with-rails
As Rails developers, we frequently use the command line. Here I will show how to switch to Z Shell using Oh My ZSH including how to make your own theme and plugins.
Add full text searching using ElasticSearch and Tire. Here I will show the steps involved in adding this search to an existing application. This is the first part in a two part series.
With the release of OmniAuth 1.0 there is a new Identity strategy which allows users to register/login with a password if they don't want to use an external provider.
Edit an attribute in-place without leaving a page using the Best In Place gem. Learn how to add validations and support for various field types.
GitHub makes it easier than ever to contribute to open source with pull requests. Here I show how to submit a pull request to the VCR project.
http://railscasts.com/episodes/300-contributing-to-open-source
Spree allows you to quickly turn a Rails project into a full eCommerce application. Here I show how to set it up and configure the look and feel of the store.
http://railscasts.com/episodes/298-getting-started-with-spree
Mercury allows you to edit a section of HTML directly in the web browser through a WYSIWYG editor. Here I show how to integrate Mercury into a Rails app and save the changes back to the database.
PJAX allows you to quickly update a section of a page using AJAX with automatic pushState support. Here I show how to use both pjax_rails and rack-pjax gems.
Vagrant allows you to run your Rails application and all of its dependencies in a portable, sharable environment. Use for development, set it up as a staging server, or experiment with a producti...
http://railscasts.com/episodes/292-virtual-machines-with-vagrant
Communicating with a SOAP API can be a daunting task. Savon makes this easier by presenting the SOAP API through a Ruby interface.
Stripe is a full-stack payment solution with very reasonable pricing and is easy to setup. See how to add it to a Rails application here. Currently only available in the US.
Clean up complex view logic using Draper. This gem provides decorators (much like presenters) which bundles view logic in an object oriented fashion. In this episode I do a step-by-step refactori...
Spork improves the loading time of your test suite by starting up your Rails application once in the background. Use it with Guard for the ultimate combo in fast feedback while doing TDD.
Active Admin allows you to quickly build an admin interface with just a few commands. Not only does it look great, but it is very customizable as shown in this episode.
Sorcery is a full-featured, modular solution to authentication which leaves the controller and view layers up to you.
http://railscasts.com/episodes/283-authentication-with-sorcery
It is incredibly easy to upgrade to Rails 3.1, but if you want to take advantage of the asset pipeline you will need to put in some extra effort. Have no fear because I walk you through each of t...
Foreman can help manage multiple processes that your Rails app depends upon when running in development. It also provides an export command to move them into production.
Pry is an alternative to IRB and sports many great features. Here I show how to integrate it into a Rails app, and how it can aid in debugging.
The asset pipeline is probably the biggest feature in Rails 3.1, but it can seem like magic at first. Here I dive into exactly how the asset pipeline works.
http://railscasts.com/episodes/279-understanding-the-asset-pipeline
Sunspot makes it easy to do full text searching through Solr. Here I show how to search on various attributes and add facets for filtering the search further.
Engines are receiving a major update in Rails 3.1. You can mount them at any path, embed assets, run generators and more. See how in this episode.
It can be difficult to test code that deals with the current time or an external web request. Here I show you how to do both using the Timecop and FakeWeb gems.
http://railscasts.com/episodes/276-testing-time-web-requests
Here I show how I would add tests to the password reset feature created in the previous episode. I use RSpec, Capybara, Factory Girl, and Guard to make request, model, and mailer specs.
It is easy to create authentication from scratch, but how do we extend it with more features? Here I add a "remember me" check box and a "forgotten password" link.
http://railscasts.com/episodes/274-remember-me-reset-password
If you need to work with geographic data, Geocoder is an excellent gem for converting addresses and coordinates, finding nearby locations, determining distances, and more!
Redcarpet is an easy-to-use gem which interprets Markdown. Here I show how to customize it and add syntax highlighting through Pygments and Albino.
Resque creates background jobs using Redis. It supports multiple queue and comes with an administration interface for monitoring and managing the queues.
Here I show off three new features in Rails 3.1 that will help with authentication: easier HTTP Basic, SecurePassword in the database, and forcing SSL.
http://railscasts.com/episodes/270-authentication-in-rails-3-1
In Rails 3.1 the controller inheritance also applies to the view layer. Here I show how to add an application template which is shared by all views, and a lookup path for overriding templates bas...
Sass extends CSS with variables, nesting, mixins and more. Here I show how to convert plain CSS to SCSS in a Rails 3.1 app.
CoffeeScript allows you to write JavaScript in a concise, elegant fashion. Here I convert JavaScript code to CoffeeScript in a Rails 3.1 app.
HTTP Streaming allows the browser to start processing the HTML response while the Rails app is still processing the rest of the request.
This is the first episode in a series covering Rails 3.1. Here I show how to install the beta and show some of the new features.
Guard watches files and runs a command after a file is modified. This allows you to automatically run tests in the background, restart your development server, reload the browser, and more.
Showing validation errors inline as the user is filling out the form can lead to a better use experience. Learn how to do this using the Client Side Validations gem.
The Ancestry gem works like a tree but also allows us to fetch deeply nested messages in a single query. It provides a method to arrange them after fetching.
Are you testing your JavaScript? Learn how to add specs using Jasmine. This episode also covers jQuery integration with jasmine-jquery.
http://railscasts.com/episodes/261-testing-javascript-with-jasmine
Faye is a subscription/publishing server which makes it easy to do push notifications within a Rails app.
The decent_exposure gem makes it convenient to share controller data with the view through methods instead of instance variables.
With the jQuery Tokeninput plugin it is easy to add an autocompleting list of entries for a many-to-many association.
Request specs in RSpec are a great way to ensure the entire application stack is working properly. Here I also show how to use capybara with integrated JavaScript testing using Selenium.
http://railscasts.com/episodes/257-request-specs-and-capybara
Internationalization is easy to add in Rails, but the YAML files can be difficult to manage. In this episode I show how to use Redis for managing the translations through a web interface.
Undo and redo behavior is easy to add with a versioning gem such as Paper Trail. Learn how to add an undo link to any model's flash message.
If you need pagination in Rails 3 try out Kaminari. It is a clean, flexible solution which uses scopes to flow nicely with Active Record queries. Did I mention it also works with Mongoid?
CarrierWave makes it easy and clean to add file uploads to your application. It supports a variety of ORMs, frameworks and image processors.
Metric Fu, Metrical, SimpleCov, Rails Best Practices, and more are covered in this episode on metrics.
MetaWhere provides a way to do complex find conditions without SQL in Active Record. MetaSearch makes it easy to create search forms with many find options.
Password authentication is not too complicated to make from scratch, it will also help to get a better understanding of how it works.
http://railscasts.com/episodes/250-authentication-from-scratch
Rails 3 comes with instrument support through the ActiveSupport::Notifications class. Call "subscribe" to listen to notifications, and "instrument" to send them.
Learn how to make a site usable offline with HTML 5 localStorage. This last part of the series covers jquery-tmpl and jquery-offline.
Learn how to make a site usable offline through an HTML 5 cache manifest. This first part of the series covers rack-offline and problems you may run into.
The new pushState function in JavaScript allows us to change the full URL with AJAX. This means the back button, reloading, and bookmark support can be easily added.
Creating new gems is easy with the `bundle gem` command. In this episode I will walk you through how this works.
Gravatar is a service for providing user avatars. See how easy it is to use in Rails in this episode.
Beanstalk is a fast and easy way to queue background tasks. Stalker provides a nice wrapper interface for creating these jobs.
Thor is an alternative to Rake. It has better support for command line arguments and provides a way to add global scripts.
Authentication is incredibly simple to add with just OmniAuth if you don't need username/password or multiple authentications per user.
Many administration pages have search, sorting, and pagination on the index page. See how to add all of this including AJAX.
http://railscasts.com/episodes/240-search-sort-paginate-with-ajax
The new Active Record query methods in Rails 3 might seem like magic at first. But in this episode I unravel how it works by browsing the Rails 3 source code.
http://railscasts.com/episodes/239-activerecord-relation-walkthrough
Mongoid is a polished, high-level Ruby gem for accessing MongoDB. Here I cover installation, adding fields, validations, associations, and keys.
It is important to use attr_accessible for security with mass assignment, but what if you need it to be dynamic based on user permissions? See how in this episode.
In this episode we continue our look at integrating OmniAuth with devise. Here I show how to set up new users with validations.
OmniAuth is an easy way to add many different authentication services to your app. In this episode we start integrating it with Devise.
Simple Form is a convenient way to generate forms with many options to customize the generated markup.
Janrain Engage (aka RPX) makes it easy to support many authentication solutions through their one service.
In this episode we continue our look into the Rails 3 router by exploring the Mapper class.
http://railscasts.com/episodes/232-routing-walkthrough-part-2
How does routing work internally in Rails 3? In this episode I'll walk you through the Rails code that makes routing possible.
Inherited Resource simplifies RESTful controllers by providing default actions which can be customized through inheritance.
If you have frequently changing data on the server side, it's helpful to automatically display this to the user as well. Here I show how to accomplish this with polling in jQuery.
Here I walk you through adding the ability to sort table columns in ascending or descending order by clicking the header.
Here we finish up this upgrade series by removing all deprecation warnings and fixing some problems in the view.
http://railscasts.com/episodes/227-upgrading-to-rails-3-part-3
Here we continue upgrading an application to Rails 3 by getting our specs up and running and going through the rails_upgrade plugin.
http://railscasts.com/episodes/226-upgrading-to-rails-3-part-2
In the first part of this series on upgrading a Rails 2 application to Rails 3, we'll start off by setting up Rails 3.0 Release Candidate in a clean environment. The rails_upgrade plugin will the...
http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1
Embedded flash notices, permanent cookies, and the details of respond_with are in this episode.
There are a number of libraries to help create graphs. Here I show how to integrate Highcharts into a Rails app.
The router in Rails 3 is fully compatible with Rack. Learn how to embed Sinatra into an app, handle redirects, and improve on Rails Metal.
It is now possible to add subdomains to Rails 3 without the use of additional plugins. Learn how in this episode.
Generating PDFs in plain Ruby can be a lot of work. Instead, consider generating PDFs from HTML using PDFKit.
In Rails 3 the non-database functionality of Active Record is extracted out into Active Model. This allows you to cleanly add validations and other features to tableless models.
Generators in Rails 3 have been rewritten to use Thor which means the code used to create a generator is quite different. Here you will learn the new way to make generators in Rails 3.
http://railscasts.com/episodes/218-making-generators-in-rails-3
See how to create a multi-step (wizard) form from scratch in this episode.
Generators in Rails 3 have been completely rewritten to be more modular. This allows you to customize any generator to fit your specific preferences.
Learn some advanced techniques regarding named scopes and get an introduction to Arel in this episode.
http://railscasts.com/episodes/215-advanced-queries-in-rails-3
A/B Testing (or Split Testing) is a way to experiment with variations in an application to see the most effective option.
If dates play an important role in your application, consider adding a date picker or calendar view as shown in this episode.
Learn how to refactor a set of conditional Active Record queries using a Dynamic Delegator.
http://railscasts.com/episodes/212-refactoring-dynamic-delegator
Rails 3 offers several new additions to validations. Here learn how to make a custom error_messages partial, reflect on validations, and clean up complex validations in a model.
Here we dive deeper into Devise by customizing how the views, routing, validations, and authentication works.
Devise is a full-featured authentication solution which handles all of the controller logic and form views for you. Learn how to set it up in this episode.
Blocks in ERB templates are handled differently in Rails 3.0 Beta 2. Learn all about it in this episode.
Here I talk about three popular choices for syntax highlighting in Rails: CodeRay, Ultraviolet and Pygments.
Action Mailer has been rewritten for Rails 3 providing a much cleaner API with its use of the Mail gem.
Keep JavaScript out of your HTML content with unobtrusive JavaScript. Here I show how Rails 3 works with this best practice.
It is easy to be vulnerable to cross site scripting attacks in earlier versions of Rails, but Rails 3 solves this by automatically escaping unsafe input.
http://railscasts.com/episodes/204-xss-protection-in-rails-3
Rails 3 sports a new routing interface. In this episode I show how to translate the old interface into the new one and show off a few new features.
Rails 3 introduces a new query interface for performing finds in Active Record. See how it works along with the changes in named scopes.
http://railscasts.com/episodes/202-active-record-queries-in-rails-3
Bundler is the way to manage gem dependencies in Rails 3.0. Learn how to install gems and lock them down in this episode.
Get started with Rails 3.0 Beta and install Ruby 1.9.1 using RVM: Ruby Version Manager. Stay tuned to the end for a challenge on giving back to open source.
Change the look and behavior of a Rails app on mobile devices. Also use jQTouch to build a native-looking interface.
Use checkboxes to edit multiple records in one form, where each one has an individual set of form fields.
http://railscasts.com/episodes/198-edit-multiple-individually
Add and remove nested model fields dynamically through JavaScript using either Prototype or jQuery.
Handling multiple models in a single form is much easier with the accepts_nested_attributes_for method. See how to use this method to handle nested model fields.
Here I show several of my favorite web applications which I found most helpful as a Ruby developer over the past year.
http://railscasts.com/episodes/195-my-favorite-web-apps-in-2009
MongoDB is a document based database engine. Learn how to access it through MongoMapper in this episode.
If you want to create a model without a database backend, you simply need to define a couple methods in the model like I show in this episode.
CanCan is a simple authorization plugin that offers a lot of flexibility. See how to use it in this episode.
http://railscasts.com/episodes/192-authorization-with-cancan
Mechanize extends the power of Nokogiri allowing you to interact with multiple pages on the site: click links, submit forms, etc.
Screen scraping is easy with Nokogiri and SelectorGadget.
http://railscasts.com/episodes/190-screen-scraping-with-nokogiri
Learn how to set up a one-to-many or many-to-many association which is entirely embedded into a single column through a string or bitmask.
Declarative authorization provides an advanced and powerful solution for role based authorization.
http://railscasts.com/episodes/188-declarative-authorization
Sometimes bad code slips into production and triggers a 500 error. Learn how to be notified of this and resolve it through integration tests.
Pickle adds many convenient Cucumber steps for generating models. Also learn about table diffs in this episode.
Learn about some of the more advanced functionality of Formtastic including handling many-to-many associations, required fields, and styling.
Formtastic is a concise way to generate form views. In this episode (part 1 of 2) I show how to generate both a simple form and a more complex one which is customized with options.
Gemcutter is a new service for hosting RubyGems, and Jeweler provides an automated way to release versions of a gem.
Present a slick user interface for cropping image attachments using Jcrop and Paperclip.
The :include and :joins options for the find method can be a little confusing because they are so similar. In this episode I show specifically when to use which option.
Over time a CSS file can become large and filled with unused selectors. In this episode I show how to use the Deadweight gem to determine which CSS selects you can remove.
Rails 2.3.4 includes a conventional way to add seed data to your application - no more including it in the migration files.
Security is important! Here I show seven different security flaws which are common to Rails applications ranging from mass assignment to CSRF protection.
If you need to keep track of a model's history of changes and switch between versions, consider using the vestal_versions gem like I show in this episode.
Searchlogic makes searching models easier than ever with its assortment of named scopes. In this episode I show you how to create simple and advanced searches.
Browser page history and bookmarks do not usually work with AJAX requests, but in this episode I show you how to remedy this problem using a simple jQuery plugin.
http://railscasts.com/episodes/175-ajax-history-and-bookmarks
Learn an easy, unobtrusive way to add AJAX functionality to an existing set of pagination links using jQuery.
Screen scraping is not pretty, but sometimes it's your only option to extract content from an external site. In this episode I show you how to fetch product prices using ScrAPI.
http://railscasts.com/episodes/173-screen-scraping-with-scrapi
Rails 2.3.3 brings us a new feature called "touch". See how to use this to auto-expire associated caches in this episode.
Is there a long running task which should be handled in the background? One of the best ways is using the delayed_job plugin like I show in this episode.
Learn how to apply OpenID to an existing Authlogic setup as I show in this episode. This builds upon the app from episode 160.
Use JavaScript to allow dynamic content in a page cache. In this episode I show you how to insert the user-specific content into a page through JavaScript.
Learn two different techniques for parsing an RSS feed using Feedzirra in this episode!
Use a virtual attribute to implement a simple tagging feature. In this episode I show you how to assign virtual attributes through a callback instead of a setter method.
http://railscasts.com/episodes/167-more-on-virtual-attributes
Metric Fu is a compilation of several tools to help find areas of code that could be improved. In this episode I show you how to setup this tool on the railscasts.com source code.
Use checkboxes to select multiple records and edit them all in one form as shown in this episode. With virtual attributes you can even edit values relatively!
Cron is great for handling recurring tasks, but it is an external dependency with a crazy syntax. In this episode I show you how to use Whenever to create cron jobs with Ruby.
Creating a social networking site often requires a self-referential association on the User model to define friends/followers. In this episode I show how to do exactly that.
http://railscasts.com/episodes/163-self-referential-association
The acts_as_tree plugin provides many methods for handling a tree based association. In this episode I show how to build a navigation system with tabs, subpages, and breadcrumbs.
Ever want to know what Rails is doing under the hood during a request? In this episode I show three different profiling tools: New Relic RPM, FiveRuns TuneUp, and Rack::Bug.
Authentication can get very complex. In this episode I show how Authlogic can handle this complexity while you stay in control of how it is presented to the user.
There is a lot more to Cucumber than I showed in an earlier episode. See how to refactor complex scenarios in this episode.
Fixtures are external dependencies which can make tests brittle and difficult to read. In this episode I show a better alternative using factories to generate the needed records.
You can improve the readability and remove duplication in RSpec by adding matchers and macros. Learn how in this episode.
If you prefer writing integration tests in ruby instead of Cucumber's plain english, consider interacting with Webrat directly as I show in this episode.
Cucumber is a high-level testing framework. In this episode we will create a new Rails application from scratch using behavior driven development.
Polymorphic associations can be perplexing. In this episode I show you how to set it up in Active Record and then move to the controller and view layer.
Prawn is an excellent Ruby library for generating PDF documents. Learn how to use it along with the Prawnto plugin in this episode.
This episode finishes up this series on Rails 2.3. Here you will learn about several smaller additions in 2.3.
Rack middleware is a way to filter a request and response coming into your application. In this episode I show how to modify the response body using middleware.
Rails Metal is a way to bypass the standard Rails request process for a performance boost. In this episode you will learn how to shave off a few milliseconds using Metal.
Rails 2.3 brings us much of the same functionality as the Rails Engines plugin. Learn how to embed one application into another in this episode.
In Rails 2.3 you can provide a template when generating a new Rails application. See how in this episode.
http://railscasts.com/episodes/148-app-templates-in-rails-2-3
Creating drag & drop sortable lists is fairly easy using Prototype and the built in helper methods. See how in this episode.
PayPal Express Checkout is easy to add to an existing ordering system. See how in this episode.
In this episode I show how to add Active Merchant's functionality to a Rails application to make a fully-functional checkout process.
http://railscasts.com/episodes/145-integrating-active-merchant
Active Merchant is a great library for handling credit card transactions. In this episode I will show you the basics of using it to communicate with PayPal's gateway.
This episode shows how to encrypt the variables passed to PayPal and verify the authenticity of the payment notifications (IPN).
PayPal's IPN (Instant Payment Notification) service allows your app to get confirmation when an order is processed. In this episode I use IPN to mark a cart as purchased.
This episode is the first in a series on handling the checkout process for orders. Here we show how to complete purchases through PayPal's Website Payments Standard service.
This episode finishes up the Rails 2.2 series by showing a few miscellaneous additions that I find useful.
In this episode I show how to nest resources through routing and go into some new additions in Rails 2.2.
Internationalization is one of the biggest additions in Rails 2.2. See how the basics work in this episode.
Rails 2.2 is out! In this episode I show how to upgrade Rails and then demonstrate one of the new additions: Memoization.
How do you use jQuery with Rails? In this episode I redo episode #43 using jQuery instead of Prototype/RJS.
Want to create a Ruby Gem instead of a Rails plugin? In this episode I will walk you through creating a gem to extend Rails.
Need to add image attachments to a model? See how with paperclip in this episode.
Do you know how to make Capistrano tasks? See how to change default deployment behavior with custom tasks in this episode.
Have you ever wanted to access helper methods outside of the view layer? In this episode I show you a couple ways to do just that.
This episode demonstrates a couple ways to redirect the user back to a previous page. Applying this to your site can help minimize the user's need to press the back button.
Need to ensure your background processes stay up and running and don't use too many resources? Check out the god gem as shown in this episode.
Creating a custom daemon to handle background tasks is surprisingly simple. In this episode I will make a daemon to handle dynamically scheduled tasks.
Need to run a task frequently in the background? Starling and Workling is a killer combination for doing just that. See how in this episode.
In need of a background process? You may be able to accomplish this with a simple Rake task. See how in this episode.
Have you ever wanted to fill up a database with a lot of test data? See how to do that in this episode using the populator and faker gems.
Discover how to dynamically change the layout using content in the database. Check out this episode for details.
You know those invitation systems where a given user can invite a number of other people to join? That's what I show you how to make in this episode.
Learn how to unleash the full potential of subdomains with the subdomain-fu Rails plugin in this episode.
Tired of juggling multiple Rails apps around with script/server? See how to set up Passenger in development so each one has its own local domain name.
This episode will show you how to make a model which isn't based on Active Record. You may want to do this if a resource isn't backed by the database.
If you need a full text search engine, Thinking Sphinx is a great solution. See why in this episode.
If you have a lot of logic associated with the data inside a session, you'll need some central location to put this logic. See how to create a session based model in this episode.
Liquid is a safe way to provide a powerful template language to the site's users. See how in this episode.
Static pages can sometimes be a little awkward to add to a Rails app. See a couple different solutions to this problem in this episode.
Selenium is a great way to test your app automatically through a browser. See how it works in this episode.
Rails 2.1 brings some new caching features which makes it very easy to cache any values including models. See how in this episode.
Ever wondered how some sites seem to have endless scrolling page with no pagination? Find out how easy it is to do this in Rails in this episode.
If you want Rails to behave a certain way, try changing it and submitting a patch. This episode will show how to do exactly this using Git.
http://railscasts.com/episodes/113-contributing-to-rails-with-git
The scoped method allows you to generate named scopes on the fly. In this episode I show how to use anonymous scopes to improve the conditional logic which was used in the previous episode on adv...
If you need to create an advanced search with a lot of fields, it may not be ideal to use a GET request as I showed in episode 37. In this episode I will show you how to handle this by creating a...
In Rails 2.1 we now have the ability to set gem dependencies. Now it's easier than ever to specify which ruby gems our rails app relies on.
Rails 2.1 keeps track of the changes you make to a model's attributes. It also allows you to see what the previous value was. But watch out for the gotcha! See this episode for details.
http://railscasts.com/episodes/109-tracking-attribute-changes
The named_scope method in Rails 2.1 makes performing finds on models very elegant and convenient. See how in this episode.
Migrations now have a timestamp as their version number in Rails 2.1. In this episode I will explain this change as well as show you some other cool additions.
In the past, time zones have been very difficult to work with, but no longer! Rails 2.1 brings with it great time zone support as you can see in this episode.
Rails 2.1 Release Candidate 1 was just released! In this episode I will show you how to install it into your Rails project.
If you're running a production site, it's a good idea to record all exceptions which occur. See how to set up a notification system which does that in this episode.
Sometimes you need to display an administrative announcement to every page on the site and give the users the ability to hide the announcement. See how in this episode.
Usually a select menu is used for setting a belongs_to association, but in this episode I will show you how to use a text field with auto completion.
http://railscasts.com/episodes/102-auto-complete-association
If you have complex view logic, this can easily lead to helper methods which call each other. See how to refactor this out into another object in this episode. This is also known as the presenter...
http://railscasts.com/episodes/101-refactoring-out-helper-object
Here's five quick tips to use in views. Be sure to catch the end of the episode where I reveal an exciting contest!
How do you handle partials which have differences depending on the action which is rendering them? Here's three suggestions for this problem.
You can use profiling to determine where the performance bottlenecks are in specific Rails actions. Watch this episode for details.
In order to improve performance of your Rails application you need to find the bottlenecks. A great starting point is your production log. In this episode you will see how to use RAWK to analyze ...
http://railscasts.com/episodes/97-analyzing-the-production-log
Git has been getting a lot of buzz lately, and for good reason. It's an excellent SCM which in many ways is more simple and powerful than subversion. See how to set up a Rails project with Git in...
See how to handle authentication and custom actions using ActiveResource in this episode.
ActiveResource allows you to easily communicate between multiple Rails applications. See how in this episode.
Action caching behaves much like page caching except it processes the controller filters. You can also make it conditional as seen in this episode.
The make_resourceful plugin is a great way to DRY up the 7 RESTful actions common in most controllers. Learn how to use it in this episode.
In this episode I walk you through an exercise in refactoring by taking a long method and making it more concise.
Sometimes you only want to cache a section of a page instead of the entire page. Fragment caching is the answer as shown in this episode.
Page caching is an efficient way to cache stateless content. In this episode I will show you how to cache the dynamic javascript we created last week.
See how to dynamically change a select menu based on another select menu using Javascript. In this episode everything is kept client side which leads to a more responsive user interface.
See how to easily generate and link to an RSS feed using new features in Rails 2.0. Watch this episode or details.
Have you ever wanted to easily log all variables? Now you can by using some advanced Ruby concepts as shown in this episode.
Application configuration shouldn't be spread throughout your code base. Instead a much better place to put it is an external YAML file. See how to do that in this episode.
In Rails 1.2 the default session store is file based. This is inefficient and difficult to maintain. In Rails 2.0 the default is now cookie based which has several benefits as you will see in thi...
http://railscasts.com/episodes/84-cookie-based-session-store
Migrations are now sexy in Rails 2.0! In this episode we will take a look at these improvements and the related rake tasks.
Rails 2.0 offers an extremely easy way to do HTTP basic authentication. See how in this episode.
In Rails 2.0, fixtures see many improvements which makes them much easier to manage. Watch this episode for details.
Rails 2.0 is almost here. One of the many features in this release is the smarter helper methods which can make your views much cleaner. Learn all about it in this Episode.
http://railscasts.com/episodes/80-simplify-views-with-rails-2-0
This more advanced episode will show you how to dynamically generate named routes by adding a method to the map object.
In this episode I will show you how to create PDF documents using the excellent PDF::Writer gem.
If the user has JavaScript disabled, the "Destroy" link might not work properly. In this episode I will explore a number of ways to work around this issue.
http://railscasts.com/episodes/77-destroy-without-javascript
The scope_out plugin will generate several helpful find methods for you automatically! It's the best way to move the find conditions into your model. Watch this episode for details.
In this third and final episode on complex forms I will show you how to edit a project and multiple tasks all in one form. This includes removing and adding tasks dynamically as well. See the sho...
See how to use Javascript and RJS to add and remove form fields dynamically. This episode will build upon the previous episode allowing you to create any number of tasks in one form the same time...
Complex forms often lead to complex controllers, but that doesn't have to be the case. In this episode see how you can create multiple models through a single form while keeping the controller cl...
Rails comes with three environments: development, test, and production. But, you aren't restricted to just these. You can add your own! See how in this episode.
Controllers are tricky to test, and there's no perfect way to do it. In this episode you will see how I test controllers, and my reasoning behind it.
http://railscasts.com/episodes/71-testing-controllers-with-rspec
In this episode you will learn how to add custom routes, make some parameters optional, and add requirements for other parameters.
Do you ever need to generate HTML code in a helper method? Placing it directly in Ruby strings is not very pretty. Learn a great way to generate HTML through Markaby in this episode.
Ever wonder how to implement OpenID authentication in your Rails app? This episode will show you how to add it to a site with an existing authentication system.
Need multiple user authentication? If so, the restful_authentication plugin is a great way to go. It will generate some basic authentication code for you which is good starting point to your auth...
Rake is one of those tools that you don't realize how powerful it is until you start using it. In this episode you will learn how to create custom rake tasks and improve them by using rake featur...
The Railscasts site has been getting a lot of comment spam in the past, but no longer. In this episode I will show you how I solved this problem by using the Akismet web service.
http://railscasts.com/episodes/65-stopping-spam-with-akismet
Rails designates one helper module per controller, but that shouldn't stop you from making custom helper modules to help structure the code. Learn how in this episode.
By default, Rails uses the model's id in the URL. What if you want to use the name of the model instead? You can change this behavior by overriding the to_param method in the model. Watch this ep...
Have you ever wanted to temporarily disable all validations? Well, ActiveRecord doesn't support this, but that doesn't mean we can't add it. This episode will show you how to open up an existing ...
This is a brief guide to sending email in Rails. See how to configure the environment, generate a mailer, create a template, and deliver the mail.
Tests which rely heavily on fixtures are brittle and can be difficult to maintain. This episode will show a couple techniques for creating tests which don't use fixtures.
When two people attempt to update the same record near the same time, one of the updates will likely be overwritten. You can solve this problem with optimistic locking.
Rails comes with many built-in generators, but what if you want to customize them or make your own? Rails gives you a great way to do this which you will learn in this episode.
Let's say you provide a select menu for setting which category a given product belongs to, but you also want the option of creating a new category by typing the name in a text field. See a great ...
http://railscasts.com/episodes/57-create-model-through-text-field
Learn all about the logger in this episode. See how to send messages to the log and how to customize it.
This episode starts off with a big, messy template. Watch as this code shrinks and becomes more readable while the interface stays the same.
This episode will show you how to debug a rails app using ruby-debug: set a breakpoint, inspect variables, change the code and more.
When an exception is raised in development you get the full error along with the stack trace. In production, only a simple message is displayed. Learn why this is and how to customize the handlin...
See how to select multiple items using checkboxes and perform an action on the selected items in this episode.
In edge rails (soon to be Rails 2.0), the built-in pagination has been moved into a plugin: classic_pagination. I recommend jumping over to the will_paginate plugin as shown in this episode.
The best way to contribute to the Rails project is to submit a patch. This episode shows how to do exactly that. There's also a surprise at the end that you don't want to miss!
The Rails API docs are very useful but can be difficult to read. This episode will give some tips on reading the docs and mention a few alternative sites for accessing the API. Update: sorry abou...
The Rails console is one of my favorite tools. This episode is packed with tips and tricks on how to get the most out of the console.
There are two different ways to set up a many-to-many association in Rails. In this episode you will see how to implement both ways along with some tips on choosing the right one for your project...
Sometimes you need to add complex/dynamic routes. This is often impossible to do in routes.rb, but do not worry. It can be accomplished with a catch-all route. See how in this episode.
This episode is packed with little RJS goodies. Learn the different ways to access an element, how to add "if" conditions and how to apply an effect to multiple elements.
RJS and AJAX can be difficult to debug. Many times you don't get any error message in the browser. Learn different techniques for solving these tricky problems in this episode.
This episode will walk you through adding AJAX functionality to a form using RJS. See how to easily update multiple elements on a page.
Several methods in rails take a hash of options as the last argument. If you are passing the same options to several methods, you can remove this duplication by using with_options. Learn all abou...
By default, validations will take place every time the model is saved. Sometimes you only want a validation to happen when certain conditions are met. See how to do that in this episode.
If you try to create a helper method which accepts a block, you will run into a few gotchas. Learn the secrets of blocks in views in this episode.
When a validation error occurs, Rails helpfully wraps the field in a div tag so you can style it. But sometimes you don't want this behavior. In this episode you will see how to customize it.
If you have a form with multiple buttons, you can detect which button was clicked by checking the passed parameters. Learn how in this episode.
A search form is quite different than other forms, this is because it does not deal with model's attributes. See a good way to add a simple search form in this episode.
This episode will walk you through setting up a Rails project on subversion. It covers some helpful tips and gotchas you may experience along the way.
REST adds many constraints. It restricts your controllers to seven actions. Normally this is okay, but sometimes you need to add your own custom actions. Learn how in this episode.
When you add a custom route, make it a named route so you have url helper methods to easily link to that new route. See episode for details.
You can sometimes remove a lot of duplication by generating methods dynamic. In this episode I will show you how to create a plugin which does exactly that.
Although Rails does allow you to edit time attributes with text fields, it's not very flexible. In this episode you will learn how to use a virtual attribute to format the time to your liking.
Learn how to use the trusty strftime method to format a time, and see how Rails allows you to save this format for later use.
If you are like me, you avoid creating page titles because it is kind of a pain. But in this episode I will show you a clean way to add titles to your pages.
Learn how to use the very useful group_by method to group an array by anything you want! In this episode I group an array of tasks by month then sort it properly.
Have you ever wanted to visually line up items in rows and columns? The in_groups_of method makes this a cinch. Just watch out for the gotcha.
Another common security issue is cross site scripting. In this episode you will see why it is so important to escape any HTML a user may submit.
Your site may be at risk! When using mass assignment, you are giving the user complete control over that model and its associations. See how a hacker might use this vulnerability and learn how to...
http://railscasts.com/episodes/26-hackers-love-mass-assignment
One of the most common security problems for dynamic sites is SQL Injection. Thankfully Rails does everything it can in solving this issue, but you still need to be aware of it.
The stack trace can be a very useful tool when it comes to debugging. Learn the ins and outs of how the stack trace works in this episode. Note: I am using an older version of the Rails bundle he...
If you need to display the record count for a has_many association, you can improve performance by caching that number in a column.
One way to improve performance is to cut down on the number of SQL queries. You can do this through eager loading. Learn all about it in this episode!
The final piece of the administration puzzle: authentication. There are many different approaches which is why I saved this step for last. This episode will cover a few techniques including the s...
http://railscasts.com/episodes/21-super-simple-authentication
In this second part of the series on administration, you will learn how to lock down the site to keep the public from accessing the administration features.
This is the first part of a three part series on building an administration system. Many developers choose to separate it completely from the public side of the site by placing it into an admin s...
Displaying flash messages in the layout can be a pain at times. In this episode you will learn an easy way to display any kind of flash message by looping through the hash.
It is often asked: how do I create a list of checkboxes for managing a HABTM association? Ask no more because this episode will show you how to do exactly that.
Keep your controllers clean and forms flexible by adding virtual attributes to your model. This very powerful technique allows you to create form fields which may not directly relate to the datab...
You can pass more than simple strings to find conditions. Arrays, ranges, and nil values can be passed as well. In this episode you will see the tricks involved with passing these odd objects to ...
Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations.
http://railscasts.com/episodes/14-performing-calculations-on-models
Be careful when storing a model in a session. It will behave differently than you expect and can easily get out of sync with the database. Instead of storing the model directly in the session, st...
http://railscasts.com/episodes/13-dangers-of-model-in-session
In the final part of this series you will see how to refactor your tests. Keeping tests clean is important because it will make testing easier to do in the future.
http://railscasts.com/episodes/12-refactoring-user-name-part-3
Testing and refactoring go hand in hand. Refactoring is all about improving code without changing its behavior. Testing is all about making sure you don't change the behavior while you are improv...
http://railscasts.com/episodes/11-refactoring-user-name-part-2
Learn how to clean up your code through refactoring. This episode will show you how to move code from the view into the model to remove duplication and simplify the view.
http://railscasts.com/episodes/10-refactoring-user-name-part-1
Are you accepting sensitive user data? Passwords, credit card numbers, etc. By default, Rails stores all submitted parameters in plain text in the logs. This episode will show you how to filter t...
If you want to change something in the layout on a per-template basis, content_for is your answer! This allows templates to specify view code that can be placed anywhere in a layout.
Everything you wanted to know about layouts: global layouts, controller layouts, shared layouts, dynamic layouts and action layouts. Yes, there really are that many ways to specify a layout.
It may have a goofy syntax, but the Symbol#to_proc feature Rails adds allows you to do simple blocks very quickly and easily.
http://railscasts.com/episodes/6-shortcut-blocks-with-symbol-to-proc
Learn how to use with_scope - a very powerful method which will allow your custom find methods to accept any find options. Just like magic!
Move a find into the model to clean up the controllers and remove duplication. Also see how you can call these custom find methods through an association.
No need to pass foreign keys in find conditions, just do the find through a has_many association.
Shorten simple finds considerably and improve readability by using the dynamic find_all_by and find_by methods.
Learn a quick way to improve performance. Just store the end result of an expensive command in an instance variable!
http://railscasts.com/episodes/1-caching-with-instance-variables