0

私は2つのモデルを持っています、

class ProcessType < ActiveRecord::Base
has_many :remarks

validates :code, :name, presence: true
end

class Remark < ActiveRecord::Base
belongs_to :process_type
belongs_to :origin

validates :description, presence: true
end

外部キーが正しく設定されており、remarksテーブルにprocess_type_id列があります。

作成フォームで、select を使用して使用可能なプロセスを表示します。

<%= simple_form_for @remark do |f| %>
  <%= collection_select(:remark, :process_type_id, ProcessType.all, :id, :name) %>

  <%= f.input :description, label: 'Description' %>
  <%= f.input :suggestion, label: 'Suggestion' %>

  <%= f.button :submit %>
<% end %>

私の問題は、備考テーブルで、保存後、プロセスの ID が常に null であることです。私は何が欠けていますか?おそらく明らかなことですが、私は今それを見ることができません。

ありがとう!

4

1 に答える 1