railscasts.com Archives - 19 December 2012, Wednesday

  • #398 Service Objects (pro)

    railscasts.com 19 Dec '12, 6am

    Models can quickly become a grab-bag of unrelated methods if behavior is constantly being pushed from the controller. Here I show how to refactor this using Concerns and Service Objects.

  • #63 Model Name in URL (revised)

    railscasts.com 17 Dec '12, 5am

    A model's ID in the URL is not very helpful to the user. Consider adding the name which can also improve SEO. Learn how to override to_param, add a slug attribute, and make a catch all route for deep nesting.

  • #393 Guest User Record

    railscasts.com 16 Dec '12, 7pm

    The first question that comes to mind is should we store the guest user account in the database if it’s just temporary? Our application is currently structured so that a user has many tasks and we use this association in the TasksController to ensure that only the current user’s tasks...

  • #397 Action View Walkthrough (pro)

    railscasts.com 10 Dec '12, 7am

    Find out exactly what Rails is doing under the hood when it renders a view template for a response. What object context handles the template? How does the lookup process work? That and more covered in this code walkthrough.

  • ASCIIcast 378 - FnordMetric (日本語): #railscasts #asciicasts #free

    #378 FnordMetric

    railscasts.com 09 Dec '12, 9am

    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.

  • #396 Importing CSV and Excel

    railscasts.com 08 Dec '12, 10pm

    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.

  • #395 Action Controller Walkthrough (pro)

    railscasts.com 03 Dec '12, 8am

    #395 Action Controller Walkthrough pro Dec 02, 2012 | 11 minutes | Controllers , Rack Do you ever wonder what goes on behind the scenes when a Rails controller handles a request? What do the "render" and "redirect_to" methods do exactly? This and more covered as we walk through the co...

  • #162 Tree-Based Navigation (revised)

    railscasts.com 02 Dec '12, 12am

    #162 Tree-Based Navigation (revised) Dec 01, 2012 | 10 minutes | Active Record , Plugins , Views If your Rails app is content-heavy, consider organizing it in a tree menu structure. Here I show how to add top-level tabs, nested links in a side bar, and breadcrumbs to go up the hierarc...

  • #394 STI and Polymorphic Associations (pro)

    railscasts.com 26 Nov '12, 4am

    #394 STI and Polymorphic Associations Nov 25, 2012 | 14 minutes | Refactoring , Active Record Single Table Inheritance (STI) can help organize branching logic into separate classes, but a polymorphic association may be a better fit if there are unique database columns. Subscribe to Wa...

  • #236 OmniAuth Part 2

    railscasts.com 24 Nov '12, 2am

    Unfortunately there is no easy solution to this problem. What we’ll do is keep the validation and redirect the user to a form where they can fix any problems if the validation fails when we try to save the new user. We’ll change the code in create so that if the validation fails when ...

  • #387 Cache Digests

    railscasts.com 23 Nov '12, 6pm

    Even though this has worked it’s annoying to have to remember to make this change every time we change a template and this is where the Cache Digests gem comes in useful. This functionality will be available by default in Rails 4 but has been extracted out into a gem so that we can us...

  • #393 Guest User Record

    railscasts.com 22 Nov '12, 2am

    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 become a permanent member afterwards.

  • #392 A Tour of State Machines (pro)

    railscasts.com 17 Nov '12, 7pm

    #392 A Tour of State Machines Nov 17, 2012 | 12 minutes | Plugins , Active Record , Testing Here I show how three popular state machine gems can be used to clean up a list of boolean/datetime fields. I also show a custom solution which keeps track of the history of events. Subscribe t...

  • #103 Site-Wide Announcements (revised)

    railscasts.com 12 Nov '12, 7pm

    #103 Site-Wide Announcements (revised) Nov 12, 2012 | 11 minutes | Active Record , Ajax , Testing Here I show how to add an announcement message at the top of every page in the application and allow the user to permanently hide it. This is all done test-first and even includes testing...

  • #384 Exploring RubyGems

    railscasts.com 11 Nov '12, 9am

    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 to do it from scratch.

    Related:
    1. #370 Ransack railscasts.com 10 Nov '12, 3pm
  • ASCIIcast 370 - Ransack (日本語): #railscasts #asciicasts #free

    #370 Ransack

    railscasts.com 10 Nov '12, 3pm

    Ransack allows you to easily build complex search forms. It also helps in adding sortable links and building a dynamic advanced search page.

    Related:
    1. #384 Exploring RubyGems railscasts.com 11 Nov '12, 9am
  • #391 Testing JavaScript with PhantomJS (pro)

    railscasts.com 08 Nov '12, 3am

    PhantomJS allows us to test JavaScript without going through a browser window. Here I show how to do this using Capybara and Poltergeist. I also give some tips on handling database transactions and skipping javascript tests.

  • #390 Turbolinks

    railscasts.com 05 Nov '12, 10pm

    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 it in Rails 3 and mention some of the gotchas.

  • Announcement

    railscasts.com 05 Nov '12, 2am

    This past week's topics are on Turbolinks and PhantomJS. I ran into some challenges with these topics which has delayed them into this week. The good news is I'm done recording the Turbolinks episode and will be releasing it tomorrow (Monday). I expect to have the PhantomJS episode up...

  • #241 Simple OmniAuth

    railscasts.com 04 Nov '12, 3am

    Some things have changed since OmniAuth version 1.0 was released. Each provider is now a separate gem that should be included in the Gemfile, and the "user_info" hash is now simply "info". The changes have been made below.

  • #147 Sortable Lists (revised)

    railscasts.com 03 Nov '12, 11pm

    This libarary is written using ARel from the ground-up. This leaves the code much cleaner than many implementations. ranked-model is also optimized to write to the database as little as possible: ranks are stored as a number between -8388607 and 8388607 (the MEDIUMINT range in MySQL)....

  • #106 Time Zones (revised)

    railscasts.com 29 Oct '12, 5am

    #106 Time Zones (revised) Oct 28, 2012 | 7 minutes | Active Support Active Support makes it easy to work with time zones. Learn how to add a Time Zone select field to a user form and watch out for the gotchas. Subscribe to Watch Episode Tweet Show Notes 2 Comments Similar Episodes < P...

    Related:
    1. #136 jQuery & Ajax (revised) railscasts.com 28 Oct '12, 9pm
  • #136 jQuery & Ajax (revised)

    railscasts.com 28 Oct '12, 9pm

    Here I go back to the basics and show how to turn a traditional Rails app into one that interacts through Ajax by adding "remote" options, JavaScript templates and a dabble of jQuery.

    Related:
    1. #106 Time Zones (revised) railscasts.com 29 Oct '12, 5am
  • #372 Bullet

    railscasts.com 28 Oct '12, 6am

    Category Load (0.2ms) SELECT "categories".* FROM "categories" ORDER BY name Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."category_id" = 3 Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."category_id" = 1 Product Load (0.2ms) SELE...

  • #389 Multitenancy with PostgreSQL (pro)

    railscasts.com 28 Oct '12, 6am

    #389 Multitenancy with PostgreSQL Oct 27, 2012 | 11 minutes | Active Record , Authorization PostgreSQL Schemas can help create a multi-tenant app by keeping data separate at the database layer. Integrating with migrations can be tricky though, so watch this episode for the full detail...

  • #352 Securing an API

    railscasts.com 25 Oct '12, 2am

    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 header.

  • #382 Tagging

    railscasts.com 21 Oct '12, 9pm

    This migration creates two tables: tags and taggings . We don’t have to create models for these as they’re included with the gem so we can get started with adding tagging to our application. We want an extra field on the page for editing an article where we can add tags for that artic...

  • #388 Multitenancy with Scopes (pro)

    railscasts.com 21 Oct '12, 1am

    #388 Multitenancy with Scopes Oct 20, 2012 | 12 minutes | Active Record , Authorization A multi-tenant application can be difficult to implement because the data for each tenant must be completely separate. Here I show how to do this using subdomains and default scopes in Active Recor...

  • #387 Cache Digests

    railscasts.com 21 Oct '12, 1am

    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 for the gotchas!