Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails 4: Appetizers

Rails 4: Appetizers

Features in Rails 4.0 -- presented at @houstonrb

Jesse Wolgamott

July 09, 2013
Tweet

More Decks by Jesse Wolgamott

Other Decks in Programming

Transcript

  1. Rails 4: Appetizers
    @jwo for @houstonrb
    Wednesday, July 10, 13

    View full-size slide

  2. Rubies
    Ruby 1.9.3 at least, prefer 2.0
    Rails 2.3 => End of Life
    Ruby 1.8.7 => End of Life
    Wednesday, July 10, 13

    View full-size slide

  3. Bootup time
    faster on Ruby 2.0 with Rails 4
    How fast?
    Cray Cray Faster
    Wednesday, July 10, 13

    View full-size slide

  4. Cache Digests
    Caches the view (partials) by the
    updated_at column
    Wednesday, July 10, 13

    View full-size slide

  5. Best if you have a upper-most
    site object.
    Example: Basecamp has an
    upper-most Account object.
    Cache Digests
    Wednesday, July 10, 13

    View full-size slide

  6. So: Add a Site object that has
    upper-most updated at.
    Cache Digests
    Wednesday, July 10, 13

    View full-size slide

  7. Will help with sidebar that does
    not directly belong to a Post.
    Cache Digests
    Wednesday, July 10, 13

    View full-size slide

  8. Uses JavaScript to pull only the
    tag
    Turbolinks
    Wednesday, July 10, 13

    View full-size slide

  9. Speeds up document based sites
    Turbolinks
    Wednesday, July 10, 13

    View full-size slide

  10. Most everybody should add
    jquery-turbolinks
    Turbolinks
    Wednesday, July 10, 13

    View full-size slide

  11. Watch out for:
    Turbolinks
    Wednesday, July 10, 13

    View full-size slide

  12. External javascript (stripe)
    Data tags on the body object
    things in the `` like
    `` tags<br/>Tubolinks<br/>Wednesday, July 10, 13<br/>

    View full-size slide

  13. Most everything, ever
    Wednesday, July 10, 13

    View full-size slide

  14. Moves Mass Assignment
    protection to the controllers
    Strong Parameters
    Wednesday, July 10, 13

    View full-size slide

  15. you have to manually remove
    attr_accessible if upgrading
    Strong Parameters
    Wednesday, July 10, 13

    View full-size slide

  16. PostgreSQL Additions
    hstore: JSON store, attributes,
    better Single Table Inheritance
    Wednesday, July 10, 13

    View full-size slide

  17. PostgreSQL Additions
    Arrays: tagging, parent child
    ancestry
    Wednesday, July 10, 13

    View full-size slide

  18. Arel Changes
    find_by_customer_id => lives!
    find(:all, conditions:
    ["customer_id = ?", 45]) => DEAD
    find(customer_id: 45) => new
    Wednesday, July 10, 13

    View full-size slide

  19. Arel Changes
    find_or_create_by_customer_id()
    => dead
    find_or_create_by(customer_id:
    45) => new!
    Wednesday, July 10, 13

    View full-size slide

  20. Arel Changes
    where(id: 45).first_or_create =>
    new hotness
    .all => deprecated
    Wednesday, July 10, 13

    View full-size slide

  21. Scope Changes
    scope :future, where("created_at
    > ?", Time.now) => syntax error
    Wednesday, July 10, 13

    View full-size slide

  22. Scope Changes
    scope :future, →
    { where("created_at > ?",
    Time.now) }
    Wednesday, July 10, 13

    View full-size slide

  23. MultiThreaded
    It's on, baby!
    Wednesday, July 10, 13

    View full-size slide

  24. Moved to Gems
    Observers
    ActiveRecord SessionStore
    ActiveResource LOL
    Action & Page Caching
    Wednesday, July 10, 13

    View full-size slide

  25. Test Directories
    test/unit => test/models
    test/functional => test/
    controllers
    Wednesday, July 10, 13

    View full-size slide

  26. Misc
    Gemfile has no Assets section
    Concerns directory is prevalent
    Wednesday, July 10, 13

    View full-size slide

  27. Misc
    /bin shows up (binstubs)
    Plugins must be moved to lib
    Wednesday, July 10, 13

    View full-size slide

  28. Misc
    ActionController::Live => (not
    alot of attention)
    Patch verb in REST
    Wednesday, July 10, 13

    View full-size slide

  29. Misc
    before_filters are now
    before_action
    Wednesday, July 10, 13

    View full-size slide

  30. Didn't Make it
    Queue API
    Async Mailers
    Wednesday, July 10, 13

    View full-size slide

  31. get more information
    http:/
    /blog.wyeworks.com/
    Rails Conf 2013 Postgres, the
    Best Tool You're Already Using
    Wednesday, July 10, 13

    View full-size slide

  32. get more information
    http:/
    /rails-upgrade-
    checklist.com
    http:/
    /upgradingtorails4.com
    http:/
    /upgradingrails.com
    Wednesday, July 10, 13

    View full-size slide

  33. Thanks!
    I’m @jwo
    Wednesday, July 10, 13

    View full-size slide