Home>

I want to save to each table from form object through intermediate table in rails
(Image, title, text are in the articles table, tag is in the tags table)

Data is not saved when I build a local server, fill out a form and submit it
At this time, there is no error message, so I am in trouble because I can not identify the root cause.
When I submit data from the form, the screen remains the same and only what I typed disappears
It will behave as if it slips through.

Corresponding source code
Intermediate table
** article.rb **
class Article</pre>
<pre><code>articles_Controller
class ArticlesController</pre>
<pre><code>article_tag_form.rb
class ArticleTagForm
  include ActiveModel :: Model
    attr_accessor: title,: text,: tag,: image,: user_id
  with_options presence: true do
    validates: title
    validates: text
    validates: tag
  end
  def save
    article = Article.create (title: title, text: text, image: image, user_id: user_id)
    Tag.create (article_id: article.id, tag_id: tag.id)
    tag = Tag.where (tag: tag) .first_or_initialize
    tag.save
  end
end
tags_controller
class TagsController</pre>
<pre><code>View file (articles/new.html.erb)
<% = form_with model: @atform, url: articles_path, class:'article-form', local: true do | f |%>
~ Abbreviation ~
<% = f.file_field: image%>
<% = f.file_field: title%>
<% = f.file_field: tag%>
<% = f.file_field: text%>
~ Abbreviation ~
<% end%>
What I tried

1) After applying binding.pry to the create action of the article controller and checking the params, the data itself (image, title, tag, text) I want to save has arrived.
2) Reconfirm the association of the intermediate table
3) Read the material of the form object and rewrite various descriptions.

Supplementary information (FW/tool version, etc.)

ruby on rails 6.0.0