<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="310269" data-post-id="310269">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Right, so this is for editing the relationship, its <code>/post/:id/relationships/comments</code>. However, that isn’t for creating new things, I just reread your initial post and now I see what you mean. This should likely be done as <code>POST /comments</code> specifying a post id to be the most REST-ish. We can add the option to ignore the base-route for some routes, that way on comment you could do: <code>create :create, route: "/post/:post_id/comments", base_route?: false</code> and have it pass the <code>post_id</code> through.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310269" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ashjsonapi-create-relationship-when-creating-resource/60040/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-310269" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310269"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="310272" data-post-id="310272">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gordoneliel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gordoneliel/120/30383_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gordoneliel
                      <span class="op-star" title="Thread Starter">
                        <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                      </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote group-Ash-Core-Team" data-username="zachdaniel" data-post="12" data-topic="60040">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/48/31980_2.png" class="avatar"> zachdaniel:</div>
<blockquote>
<p>a post id to be the most REST-ish.</p>
</blockquote>
</aside>
<p>Thats not bad. Although, would I have to have 2 create actions? When creating a <code>Post</code>, I create a <code>Comment</code> alongside through the managed relationship, but If I also want to create a <code>Comment</code> for a <code>Post</code>, I need another create action that specifies an argument <code>post, :map, allow_nil? false</code>.</p>
<p>Eg.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Comment resource:

create :create_direct do
  argument :post, :map, allow_nil?: false
  accept [...]
  change manage_relationship(:post, type: :append)
end

create :create_managed do
  primary? true
  accept [...]
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310272" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ashjsonapi-create-relationship-when-creating-resource/60040/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-310272" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310272"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="310273" data-post-id="310273">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can simplify a bit if you do</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">belongs_to :post, Post do
  attribute_writable? true
end
</code></pre>
<p>then they can provide the <code>post_id</code> directly as an input. Then</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">create :create do
  accept [..., :post_id]
  primary? true
end
</code></pre>
<p>And then use that one action in both. Since <code>post_id</code> is not <code>nullable</code>, you will always be prevented from creating a comment with no post, and the <code>manage_relationship</code> will set <code>post_id</code> automatically.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310273" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ashjsonapi-create-relationship-when-creating-resource/60040/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-310273" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310273"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>