0
私はセルを備えたテーブルを持っています。私は各セルフォームbelongs_to
行、列、およびテーブル作成する方法を繭を使用複数の継承を持つHTML表形式、繭で?
?例については
:
# Table
class Roster < ApplicationRecord
has_many :timeslots, inverse_of: :roster
has_many :games, inverse_of: :roster
accepts_nested_attributes_for :timeslots, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :games, reject_if: :all_blank, allow_destroy: true
end
# Column
class Court < ApplicationRecord
belongs_to :roster
has_many :games
accepts_nested_attributes_for :games, reject_if: :all_blank, allow_destroy: true
end
# Row
class Timeslot < ApplicationRecord
belongs_to :roster
has_many :games
accepts_nested_attributes_for :games, reject_if: :all_blank, allow_destroy: true
end
# Cell
class Game < ApplicationRecord
belongs_to :timeslot
belongs_to :roster
end
私は各ゲームの:timeslot_id
のための隠された<input>
で今しようと:court_id
ています唯一の問題は、タイムスロットと、裁判所が保存される前に、あなたがIDを取得することはできませんです。各ゲームは、彼らがしている行/列の隠された<input>
を持っているため、私が取り組んでミリアンペア、他のアイデアはにある
ブートストラップのようなグリッドシステムを使用する方が簡単でしょうか?しかし、とにかく:実際のhtmlの 'table'(それは単なる難しい)を使うことができないべきではない理由はありません。だからあなたはどこにいらっしゃいましたか? – nathanvda
私はそれを理解することができたと思う。バックエンドのルビーよりもフロントエンドで多くのjavascriptをやっていました。私の問題は、各セルを列と行に属するようにすることでした。 – DrevanTonder