Report abuse

User

1
2
3
4
(from nifty authentication)

  has_many :contracts

Contract

1
2
3
4
5
6
7
class Contract < ActiveRecord::Base

  belongs_to :user
  has_many :sections

end

Section

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

1
2
3
4
5
6
7
class SectionMap < ActiveRecord::Base

  belongs_to :widget, :polymorphic => true
  belongs_to :section

end

Contact

1
2
3
4
5
6
class Contact < ActiveRecord::Base

   has_one :section_map, :as => :widget

end

Acknowledgment

1
2
3
4
5
6
class Acknowledgment < ActiveRecord::Base

  has_one :section_map, :as => :widget

end