I m a newbie on Rails I have User and Attachment model and has_many through relationships. I want to add data,it can be more than one, to third model which is intermediate form when I create the attachment data. I can save the attachment data but I don't know how I save data to third model.Here my files
attachments/new.html.erb
<%= form_for(@attachment) do |f| %>
<div class="field">
<%= f.label :filename, "File Name" %><br>
<%= f.text_field :filename %>
</div><br />
<div class="field">
<%= f.label :file, "File" %><br>
<%= f.file_field :file %>
</div> <br />
<div class="actions">
<%= f.submit "Dosya yükle" %>
</div>
<% end %>
attachments_controller.rb
def new
@attachment = Attachment.new
end
def create
@attachment = Attachment.new(file_params)
if @attachment.save
redirect_to some_path
else
render action: 'new'
end
end
user.rb
has_many :interforms
has_many :attachments, through: :interforms
attachment.rb
has_many :interforms
has_many :users, through: :interforms
interform.rb
belongs_to :user
belongs_to :attachment
My question is how I add data to interform when I add to attachment
Edit : I didn't have any routes for interforms right now