Last active
April 15, 2016 19:38
-
-
Save roooodcastro/c7c928e82d00e032e991848cd958eaca to your computer and use it in GitHub Desktop.
Proposed Rails Presenter Strategy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'presenters/aluno_presenter' | |
class Aluno < ActiveRecord::Base | |
include Presenters::AlunoPresenter | |
def save | |
# ... | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Presenters::AlunoPresenter | |
def formatted_name | |
name.mb_chars.titlecase | |
end | |
def other_method_to_present_aluno_to_the_view | |
# But without using any helper methods, and without building HTML/template elements directly | |
# This is done using view helpers in /helpers/ | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Hello, <%= @aluno.formatted_name %></h1> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment