Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## User (from nifty authentication) has_many :contracts ## Contract class Contract < ActiveRecord::Base belongs_to :user has_many :sections end ## Section class Section < ActiveRecord::Base belongs_to :contract has_many :section_maps after_update :save_widgets def existing_widget_attributes=(widget_attributes) widgets.each do |widget| attributes = widget_attributes[widget.id.to_s] widget.attributes = attributes end end def save_widgets widgets.each do |object| widgets.save(false) end end end ## Section Map class SectionMap < ActiveRecord::Base belongs_to :widget, :polymorphic => true belongs_to :section end ## Contact class Contact < ActiveRecord::Base has_one :section_map, :as => :widget end ## Acknowledgment class Acknowledgment < ActiveRecord::Base has_one :section_map, :as => :widget end
This paste will be private.
From the Design Piracy series on my blog: