Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created February 26, 2012 06:17
Show Gist options
  • Save jgaskins/1914273 to your computer and use it in GitHub Desktop.
Save jgaskins/1914273 to your computer and use it in GitHub Desktop.
Perpetuity ActiveModel wrapper
require 'article'
require 'user'
class ArticleMapper < Perpetuity::Mapper
include Perpetuity::ActiveModelWrapper
attribute :title, String
attribute :body, String
attribute :author, User
end
class ArticlesController < ApplicationController
def edit
@article = ArticleMapper.find(params[:id])
@article_mapper = ArticleMapper.new(article)
end
end
=form_for @article_mapper do |f|
p.field=f.text_field :title
p.field=f.text_area :body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment