Skip to content

halogenandtoast/presentable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

Releases

No releases published

Packages

No packages published

Languages