accescible_app/app/models/portlets/table_content.rb
Nicolas Bally e4e4463be1 suite
2021-05-15 15:14:41 +02:00

27 lines
528 B
Ruby

# -*- encoding : utf-8 -*-
class TableContent < ActiveRecord::Base
has_one :portlet, :as => :content, :dependent => :destroy
has_many :table_rows, -> {order("position")}
has_many :cel_tables, :through => :table_rows
after_create do
self.nbr_rows.to_i.times do
table_row = TableRow.create(:position => 1, :table_content_id => self.id)
self.nbr_cols.to_i.times do
cel_table = CelTable.new
table_row.cel_tables << cel_table
end
end
end
end