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

shinosakarb #11 Rails 4 Pattenrs

murajun1978
December 20, 2014

shinosakarb #11 Rails 4 Pattenrs

murajun1978

December 20, 2014
Tweet

More Decks by murajun1978

Other Decks in Programming

Transcript

  1. Rails 4 Patterns
    Shinosaka.rb #11

    View full-size slide

  2. me
    @murajun1978

    View full-size slide

  3. Rails 4.2.0 has been
    released!

    View full-size slide

  4. new goodies
    ActionMailer #deliver_later
    Active Job
    Web Console
    Good!
    Adequate Record

    View full-size slide

  5. Agenda
    • ActiveRecord::Callbacks
    • Scope
    • ActiveSupport::Concern
    • Decorator
    • ActiveDecorator vs Draper
    • Helper

    View full-size slide

  6. Fat Controller

    View full-size slide

  7. Fat Controller

    View full-size slide

  8. ActiveRecord::Callbacks

    View full-size slide

  9. Scope
    NoMethodError!!

    View full-size slide

  10. ActiveSupport::Concern
    app/models/concerns/…
    Class method
    duplicate :(

    View full-size slide

  11. Decorator
    ActiveDecorator
    view logic… :(
    $ rails g decorator Post
    app/decorators/…

    View full-size slide

  12. Decorator
    Which do you like?
    ActiveDecorator Draper
    https://github.com/drapergem/draper
    https://github.com/amatsuda/active_decorator

    View full-size slide

  13. Helper
    content_tag_for

    http://localhost/posts#post_123

    View full-size slide