Sha256: 913a328096bd84700316b45eaa6507691da900cccb748f0d018d86e1576af034
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
ActWithBag ========== In Gemfile: gem 'act_with_bag' Bag helps when fields in a table are not yet settled down or when many fields without business logic are required. Install one bag in a table to collect many fields. Additional fields or removal of them are easy. No migration is required for new fields. Keep in mind that the collection is kept in a YAML bag, i.e. SQL commands can't access the fields. Boolean and Date fields require explicit typing, others are treated as string. Technical background: getters and putters are injected into models. If baggies of type :date are being used then params must be corrected before an update_attributes. Warning: :date fields are not well integrated; avoid them. Obsolete fields are deleted before_save by: delete_from_bag :field Example ======= In model: class Order < ActiveRecord::Base add_to_bag :name, :color, :description, {:active => :boolean}, {:paused_at => :date} In controller: class OrdersController < ApplicationController def create params = Order.merge({}, self.params) # only if type :date is being used @order = Order.new(params[:order]) def update @order = Order.find(params[:id]) params = Order.merge(@order.bag, self.params) # only if type :date is being used Test ==== rake Copyright (c) 2009-2011 [Dittmar Krall], released under the MIT license
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
act_with_bag-0.4.4 | README |
act_with_bag-0.4.2 | README |
act_with_bag-0.4.0 | README |