Skip to content

Instantly share code, notes, and snippets.

@roooodcastro
Last active April 15, 2016 19:38
Show Gist options
  • Save roooodcastro/c7c928e82d00e032e991848cd958eaca to your computer and use it in GitHub Desktop.
Save roooodcastro/c7c928e82d00e032e991848cd958eaca to your computer and use it in GitHub Desktop.
Proposed Rails Presenter Strategy
require 'presenters/aluno_presenter'
class Aluno < ActiveRecord::Base
include Presenters::AlunoPresenter
def save
# ...
end
end
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
<h1>Hello, <%= @aluno.formatted_name %></h1>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment