Created
February 26, 2012 06:17
-
-
Save jgaskins/1914273 to your computer and use it in GitHub Desktop.
Perpetuity ActiveModel wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'article' | |
require 'user' | |
class ArticleMapper < Perpetuity::Mapper | |
include Perpetuity::ActiveModelWrapper | |
attribute :title, String | |
attribute :body, String | |
attribute :author, User | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ApplicationController | |
def edit | |
@article = ArticleMapper.find(params[:id]) | |
@article_mapper = ArticleMapper.new(article) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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