I would appreciate it if you could answer. Thank you!

I want the information to be saved in the intermediate table (group_users) when I create a new group.
user uses devise.

Now, if you enter the required information on the new group creation page and submit it, the information will be saved in the groups table.
However, nothing is saved in the group_users table, which is an intermediate table.
* No error message is displayed.

Corresponding source code
  • routes.rb
Rails.application.routes.draw do
  devise_for: users
  root to: "tweets # index"
  resources: groups, only: [: new,: create]
  • migration
class CreateGroups</pre>
<pre><code>class CreateGroupUsers</pre>
<pre><code>class User</pre>
<pre><code>class Group</pre>
<pre><code>class GroupUser</pre>
<pre><code>class GroupsController</pre>
   Create new group 
<% = form_with model: @group, local: true do | f |%>
      <% = f.label: group name, class:'chat-group-form__label'%>
      <% = f.text_field: name, class:'chat__group_name chat-group-form__input', placeholder:'Please enter the group name'%>
      <% = f.label: Group content, class:'chat-group-form__label'%>
      <% = f.text_field: content, class:'chat__group_name chat-group-form__input', placeholder:'Please enter the contents of the group'%>
      <% = f.submit class:'chat-group-form__action-btn'%>
<% end%>