Episode

Поделиться
HTML-код
  • Опубликовано: 11 ноя 2024

Комментарии • 13

  • @haroldpepete
    @haroldpepete 6 лет назад +6

    Thank, ROR got too many option, this is why some people don't like it, personally i think that ROR is the most robust an complete MVC pattern software. Thank to DRIFTING RUBY for maintain updated

  • @vicentedpsantos
    @vicentedpsantos 5 лет назад

    Great explanation! Thanks!

  • @jacquisurfer1548
    @jacquisurfer1548 Год назад

    Can anyone explain why "super(@model)" is needed in UserPresenter class ?

  • @TheDhastan
    @TheDhastan 6 лет назад

    Cool!

  • @jl789nz
    @jl789nz 2 года назад

    I'm fairly new too rails, but I'm struggling to see how this is a better way of doing things. Seems like it's obfuscating code, with out much benefit.

    • @CyrilCommando
      @CyrilCommando Год назад

      Yup. Programmers do that often. If you haven't watched "Object oriented programming is bad" by Brian Will, I highly recommend it. As for RoR, it's probably better that you just write some simple conversion logic (we're talking like

  • @ameft
    @ameft 6 лет назад +1

    Make sense, thank you! But wouldn't it be nice to have this kind of functionality wrapped in a gem like for draper?

  • @em_the_bee
    @em_the_bee 2 года назад

    4:00 you actually don't need to prepend @model if you inherit from SimpleDelegator and call super(@model). Great video, but it would be even better if you didn't take the leap with the Delegator and shown why just a class without delegating would be inconvenient

  • @MOOnLight2k
    @MOOnLight2k 5 лет назад

    Well explained, but I still have a question. Wouldn't it be better to just import all of the helpers inside ApplicationPresenter and don't provide a view context on every presenters initalization because it's ruining DRY by not allowing to use this presenter in other cases, different to view render, like sending an email or creating an PDF with invoice, etc ?????

  • @codatrainer3988
    @codatrainer3988 3 года назад

    Very nice explained but I think you can even create without initializing presenter following is simplified version.
    ```
    class UserPresenter < SimpleDelegator
    include ActionView::Helpers::NumberHelper
    def full_name
    "#{first_name} #{last_name}"
    end
    def birth_year
    return nill unless birthdate
    birthdate.year
    end
    def nickel_per_year
    return nil unless birthdate
    difference = Date.today.year - birth_year
    number_to_currency(difference * 0.05)
    end
    end```

  • @skunksmisery
    @skunksmisery 5 лет назад

    great until the 7 minute mark, wtf is a Klass?

    • @DriftingRuby
      @DriftingRuby  5 лет назад

      class is a reserved keyword in ruby, so some will use klass instead when defining a variable which points to a Class.

    • @skunksmisery
      @skunksmisery 5 лет назад

      @@DriftingRuby Thanks.... explaining things like these are the steps that are often missed in tutorials, and which made Railscasts the gold standard. Your tutorials are also very good (except when you start renaming things without explanation :p )