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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kelvinst" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kelvinst/120/10173_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kelvinst
                    <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 no-group" data-username="zimt28" data-post="41" data-topic="7747">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zimt28/48/9933_2.png" class="avatar"> zimt28:</div>
<blockquote>
<p>Is it possible to reference a table, say <code>clients</code> where the prefix is dynamic?</p>
</blockquote>
</aside>
<p>You mean from another table in the public prefix for example? I don’t think something like that is possible, since the relation would need to point to multiple tables. But if you mean referencing it from another table inside the same dynamic prefix, you can totally do that.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="148018" 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/triplex-a-complete-solution-to-multi-tenancy-with-pg-schemas/7747/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-148018" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="148018"
                     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 #41"></div>
  </section>
</div>
    <div class="postbit" id="182510" data-post-id="182510">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sashman" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sashman/120/7750_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sashman
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Can anyone provide full example of Router + Controller + Ecto usage? I’m interested to find out how to propagate the tenant name down to the service layer. My current thinking is</p>
<p>router.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  pipeline :tenant do
    plug Triplex.SubdomainPlug,
      endpoint: CcbApiWeb.Endpoint

    plug Triplex.EnsurePlug,
      failure_callback: &amp;CcbApiWeb.Tenant.Helper.ensure_loaded_failure/2
  end

  scope "/api", CcbApiWeb do
    pipe_through :api
    ...

    scope "/" do
      pipe_through :tenant

      resources "/customers", CustomerController, except: [:new, :edit]
   ...
</code></pre>
<p>customer_controller.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">...
  def index(conn, _params) do
    customers = Customers.list_customers(conn.assigns)
    render(conn, "index.json", customers: customers)
  end
...
</code></pre>
<p>customers.ex</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def list_customers(assigns) do
    Repo.all(Customer, prefix: Triplex.to_prefix(assigns))
  end
</code></pre>
<p>Are there any macros that can help me out here?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="182510" 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/triplex-a-complete-solution-to-multi-tenancy-with-pg-schemas/7747/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-182510" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="182510"
                     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 #42"></div>
  </section>
</div>
    <div class="postbit" id="183140" data-post-id="183140">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kelvinst" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kelvinst/120/10173_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kelvinst
                    <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">
								<p>I particularly prefer to propagate the tenant myself, so I would go the way you did it too. But instead of sending the whole assigns, you could actually send only the loaded tenant to the context.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="183140" 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/triplex-a-complete-solution-to-multi-tenancy-with-pg-schemas/7747/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-183140" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="183140"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></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>