Skip to content

Instantly share code, notes, and snippets.

@ohcibi
Created April 24, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohcibi/2480945 to your computer and use it in GitHub Desktop.
Save ohcibi/2480945 to your computer and use it in GitHub Desktop.
class Page < ActiveRecord::Base
attr_accessible :title
has_many :page_widgets
has_many :widgets, through: :page_widgets
end
class PageWidget < ActiveRecord::Base
attr_accessible :height, :offset_x, :offset_y, :width
belongs_to :page
belongs_to :widget
end
class Widget < ActiveRecord::Base
attr_accessible :content, :title
has_many :page_widgets
has_many :pages, through: :page_widgets
def put_on page
pages << page
# return new page_widget here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment