Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (16 sloc) 595 Bytes

Presentable

Making presenters easy and fun!

Setup for Rails

Update config/environment.rb

config.load_paths += %W( #{RAILS_ROOT}/app/presenters )

Create a presenter class

class PostPresenter < Presenter
  def title
    "#{original_title} - <span class='date'>#{created_at.strftime('%B %d')}</span>" # reference old values by prefixing them with original_
  end
end

Call present on your instance

@post = Post.find(params[:id]).presenter

Use presenter methods in your view

<h2><%= @post.title %></h2>
<p>@post.body</p>