ruby
1class TestData < ApplicationRecord 2 3 has_one :start_file, class_name: 'AttachmentFile::Start', as: :attachable, inverse_of: :attachable 4 has_one :end_file, class_name: 'AttachmentFile::End', as: :attachable, inverse_of: :attachable 5 6 accepts_nested_attributes_for :import_file 7 accepts_nested_attributes_for :error_csv 8end 9 10class AttachmentFile::Start < AttachmentFile; end 11class AttachmentFile::End < AttachmentFile; end 12
同じモデルでhas_oneを二つ別々に持ちたいのですが、上の様にしてもstart_fileとend_fileが同じになってしまいます。
何か解決する手段があればご教授いただきたいです。
ruby
1# Table name: attachment_files 2# 3# id :bigint(8) not null, primary key 4# attachable_type :string(255) not null 5# attachable_id :bigint(8) not null 6# file_data :text(65535) not null 7# file_type :integer default(NULL), not null 8# created_at :datetime not null 9# updated_at :datetime not null 10 11
回答2件
あなたの回答
tips
プレビュー