Sha256: 21fbc6bfb945971d6d0bcad405845a404633b820df993ec63894c9138b01fbc0
Contents?: true
Size: 723 Bytes
Versions: 4
Compression:
Stored size: 723 Bytes
Contents
# encoding: utf-8 class Posts def self.dispatcher(action) Proc.new do |env| self.new(env).send(action) end end def initialize(env) @env = env end def index end def new @form ||= PostForm.new @form.attributes[:method] = "POST" end def edit @form ||= PostForm.new @form.attributes[:method] = "PUT" end def create(raw_data) @form = PostForm.new(nil, raw_data) if @form.save redirect url(:posts) else self.new end end def update(id, raw_data) @form = PostForm.new(nil, raw_data) if @form.update(id) redirect url(:posts) else self.edit end end end map("/posts") do Posts.dispatcher(:index) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
formidable-0.1.2 | examples/posts/config.ru |
formidable-0.1.1 | examples/posts/config.ru |
formidable-0.1 | examples/posts/config.ru |
formidable-0.0.1 | examples/posts/config.ru |