railscasts.com Archives - 01 November 2013, Friday

What you could also do is to have Article, Photo, and Event be STI subclasses and have their superclass has_many :comments. Both approaches work of course but newbies might want to also consider STI - it keeps the code cleaner for counter_cache, adding more common functionality (e.g. ...

#137 Memoization (revised) Aug 18, 2012 | 9 minutes | Performance , Caching Memoization is a convenient way to cache a method's response. Here I show several ways to accomplish this from scratch since the ActiveSupport::Memoizable module has been deprecated. Subscribe to Watch Episode...

AngularJS is an awesome framework for easily creating rich, client-side applications. Its powerful bindings allow you to do a lot with very little code. Here I show how to integrate Angular with a Rails app.

Related:

The second part of the code builds a string of the form fields for that object so that we can insert them into the javascript function that will add them to the form when a link is clicked. It does this by calling the appropriate partial code, passing in the form builder. The only rea...

$ rake middleware use ActionDispatch::Static use Rack::Lock use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007f9704a76118> use Rack::Runtime use ActionDispatch::RequestId use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::DebugExceptions use...

You might wonder what the point of this is and if it’s worth browsing around other code, but in my opinion it is as reading Ruby code written by other people is a great way of improving your own Ruby skills. You’ll see tricks and techniques that other people use that you can use later...

Now that we don’t have to start up our Rails application every time we run one of these commands the output appears much sooner. Zeus works by preloading Rails in the different environments, development and test, and if we had Cucumber set up in this app it would work for that as well...

#158 Factories not Fixtures (revised) Oct 27, 2011 | 9 minutes | Testing , Tools Fixtures are external dependencies which can make tests brittle and difficult to read. In this episode I show how to use Factory Girl to generate the needed records directly in the tests.

A useful side-effect of this is that it helps us to get a better understanding of how Rails works. For our error we can see that the check_box method is triggered in our code and working through the stack trace we’ll see that this method is called on a form builder and we can carry on...

plugin comes in. This makes it easier to use the name of a model in a URL without having to prefix it with an id . The gem has a number of features but before we look into them we’ll see what’s involved in adding it to our application. As ever, the first thing we’ll need to do is add ...

May 14, 2007 | 5 minutes | Active Support , Views 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. Click to Play Video ▶ Tweet Download: mp4 Full Size H.264 Video (8.96 MB) m4v Smaller H.264 Video (5.69 MB) w...

Updated RailsCasts Status I had originally planned to return to RailsCasts on September 2, however I do not feel ready yet. I don't want to return until I am fully ready to avoid getting burnt out. It is hard to predict exactly when that will be, but in the meantime I have extended al...

Related:

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 system, navigation, tooltips and more.