-
Notifications
You must be signed in to change notification settings - Fork 1
Arhont/active-record-presenters
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Active Record Presenters ======================== Object oriented helpers. An alternative to passing objects around to methods defined in app/helpers/*. # app/presenters/post_presenter.rb class PostPresenter < Presenter def timestamp "Created #{object.created_at.strftime("%d")}" end end <%= @post.presents.timestamp %> Instead of: def post_timestamp(post) "Created #{post.created_at.strftime("%d")}" end <%= post_timestamp(@post) %> Inside presenters, you can access these two methods: * object -- the model instance in question * helpers -- call any helper on this method Example: class PostPresenter < Presenter def body helpers.textilize(object.body) end end <%= @post.presents.body %> Presenters are generated with "ruby script/generate presenter [my_model]". Installation instructions ========================= * Install the plugin with 'ruby script/plugin install git://github.com/leethal/active-record-presenters.git' * ???? * Profit! FYI === This plugin is not the same as ActivePresenter (http://github.com/giraffesoft/active_presenter/tree). ActivePresenter is for handling multiple models in one form. Active Record Presenters (this plugin) is an alternative/supplement to view helpers. I should probably change the name of this plugin to avoid the name clash.
About
Object oriented helpers for Rails/ActiveRecord
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published