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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I wanted to provide some feedback on the changes in Phoenix 1.3.</p>
<p>First, the organization for a new umbrella app is really nice.  Moving my models into a separate OTP app that the web app references is something I pieced together in 1.2 with examples posted on this forum.  (<a href="https://github.com/wojtekmach/acme_bank" class="inline-onebox" rel="noopener nofollow ugc">GitHub - wojtekmach/acme_bank: An example ☂ project · GitHub</a>)</p>
<p>Grouping up functional areas for the models is probably a good idea.  It happens naturally over the course of a larger application, and it’s a solid DDD approach, so I am for that.</p>
<p>Where I am having trouble is the top level files we will be maintaining, like <code>accounts.ex</code> and <code>accounts_test.exs</code>.</p>
<ol>
<li>
<p>Many functions<br>
These files are going to become unwieldy very quickly: 3 models is 21 functions and that’s just getting started.</p>
</li>
<li>
<p>That are very similar<br>
These files have repeated functionality that is extremely similar across models.  <code>Accounts.list_users</code>, <code>Accounts.list_roles</code>, <code>Accounts.list_permissions</code>.  My thought is that I should get <code>Accounts.User.list / get! / update / etc</code> for free through a <code>use</code>d module.  I am trying to weigh that against being too OO, but I think there is precedence with <code>user Genserver</code> and providing callbacks to supply arguments the common functionality will use.  A function that provides a <code>changeset</code> function and <code>struct/map</code> type to a <code>Model</code> module is what comes to mind.</p>
</li>
<li>
<p>Changesets aren’t by their schemas<br>
I am finding the natural flow for me is to look at my schema while writing my changeset logic, and even though I can open it in another tab, it feels like it should be in the same file.</p>
</li>
</ol>
<p>I like the 1.2 idea of testing models separate from repo side effects.  I don’t want to lock into existing ways, but I think some of the new changes are going to result in more code the end developers will have to write and maintain.</p>
<p>I realize I am free to do as I please, and that a lot of thought went into these changes.  Overall the changes are great, but maybe the above can help make things a little smoother.  Thanks.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26186" data-batch-url="/posts/batch_likers">
                        4
                      </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/phoenix-v1-3-0-rc-0-released/3947/63">Post #62</a>
	                </div>
	            </div>
              <div id="likers-container-26186" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26186"
                     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 #62"></div>
  </section>
</div>
    <div class="postbit" id="26190" data-post-id="26190">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="chrismccord" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chrismccord/120/24233_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  chrismccord
                    <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 class="user-title">
									<span>Creator of Phoenix</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the feedback! Answers inline.</p>
<aside class="quote no-group quote-modified" data-username="rschooley" data-post="63" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<ol>
<li>Many functions. These files are going to become unwieldy very quickly: 3 models is 21 functions and that’s just getting started.</li>
</ol>
</blockquote>
</aside>
<p>21 functions is not a huge API surface area. I can understand the concern of God Modules, but as previous posts have shown, it’s difficult to make suggestions if a module is doing too much without concrete use cases. Also note that just because you have 3 entities in your context, it does not necessarily mean you’ll have the same conventional functions for all of them. Sometimes you will, sometimes you won’t. For example, imagine a a bank system with a Deposit, an Account, and a AccountHolder. Under this case, you likely wouldn’t expose the crud functions for deposits at all, instead delegating the details of that deeper into the system. That’s not to say you won’t end up with &gt; 21 functions. As José has said, it’s easier to start with the parts of your app in the same place, then see where they can be separated than trying to predict the future up front. If these parts of your app are necessarily coupled and depend on one another, grouping together their functionality is not a problem. If you have specific examples we can try to say more.</p>
<aside class="quote no-group quote-modified" data-username="rschooley" data-post="63" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<ol start="2">
<li>That are very similarThese files have repeated functionality that is extremely similar across models.  Accounts.list_users, Accounts.list_roles, Accounts.list_permissions.  My thought is that I should get Accounts.User.list / get! / update / etc for free through a used module…</li>
</ol>
</blockquote>
</aside>
<p>There is duplication here if all your entities are using ecto, but I don’t feel this is a good candidate for code injection. <code>use GenServer</code> is injecting code to satisfy a behaviour with known functionality. The point of your contexts is that they are the boundary to the internal details of listing users/roles/permissions. If your user permissions are stored in ets, but the users and roles in Postgres, then you can’t just inject code. I also would prefer to see an explicit call when viewing the module. If you want to offload the query generation that you handle the same way, then I would do something like this:</p>
<pre><code>def list_users(opts \\ []) do
  opts
  |&gt; QueryBuilder.apply_opts(User)
  |&gt; Repo.all()
end

def list_permissions(user, opts) do
  from(p in assoc(user, :permissions))
  |&gt; QueryBuilder.apply_opts(opts)
  |&gt; Repo.all()
end
</code></pre>
<p>Notice how even using your user and permission example, our “duplicated” api for listing resources already contains some differences. For example, list/create/update/delete_permissions is going to take the <code>user</code> as an argument, where the generated functions won’t have such scoping. I don’t feel code injection is best here, but there are still ways to offload shared querying by delegating outside, as <code>QueryBuilder</code> in my example that would know how to build an Ecto query given some options.</p>
<aside class="quote no-group" data-username="rschooley" data-post="63" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<ol start="3">
<li>Changesets aren’t by their schemasI am finding the natural flow for me is to look at my schema while writing my changeset logic, and even though I can open it in another tab, it feels like it should be in the same file.</li>
</ol>
</blockquote>
</aside>
<p>Changests can be for any source, and I usually go the other way and collocate them close the user input or changes I am modeling. That said, there is nothing stopping you from collocating changeset functions with the schema. It’s a valid option if that suits you, but since my boundaries expose my Schema structs publicly, I like to keep private things like changeset building out of the module.</p>
<aside class="quote no-group" data-username="rschooley" data-post="63" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<p>I like the 1.2 idea of testing models separate from repo side effects.  I don’t want to lock into existing ways, but I think some of the new changes are going to result in more code the end developers will have to write and maintain.</p>
</blockquote>
</aside>
<p>This is still a good approach, but since Ecto achieved parallel database transactions, this design is no longer an essential part of your testing strategy. I actually find it easier to write and maintain tests that simply hit the database internally as needed than those that go through hoops to manage or stub db calls.</p>
<aside class="quote no-group" data-username="rschooley" data-post="63" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<p>I think some of the new changes are going to result in more code the end developers will have to write and maintain.</p>
</blockquote>
</aside>
<p>The first part of this sentence is absolutely true – the new context generators will result in more code than throwing a Repo.insert in the controller, <em>but</em> as far as maintenance is concerned seeing the LOC that the new generators build vs the old ones is not a good maintenance indicator. For example, every time you duplicate <code>Repo.insert / Ecto.build_assoc/ etc</code> calls in multiple controllers, channels, other modules, etc, you are placing a future burden on yourself. Compound this over a few years, and it will be a massive maintenance cost. Imagine needing to offload persistence of parts of the system to another store, or another app entirely? Now you have to refactor every  part of the system that this “simpler” code touched.</p>
<p>Every decision we make in software is a trade-off, but I feel the current approach maintenance wise is an absolute win, with the potential for slightly more effort up front. We feel that effort is going to be worth it <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26190" data-batch-url="/posts/batch_likers">
                        9
                      </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/phoenix-v1-3-0-rc-0-released/3947/64">Post #63</a>
	                </div>
	            </div>
              <div id="likers-container-26190" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26190"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
    <div class="postbit" id="26191" data-post-id="26191">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I wanted to a quick follow up of a possible approach I talked about.  Someone who is better at Elixir can probably make this better, but it shows a quick pass at it.</p>
<p>I think the benefit of this is not every model has to test <code>all</code>.  That should be something out of the box, and having an opinion about a common way of doing this is ok.</p>
<p>I realize this is maybe like ActiveRecord, but Ecto defines similar methods.  The difference is in Phoenix we have to explicitly stitch together our schemas and the Ecto methods we need to call.  This would make that all transparent and tested separately.</p>
<p><a href="https://gist.github.com/rschooley/d2bf87f6cc3085e66a50103763b6e23b" class="onebox" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/rschooley/d2bf87f6cc3085e66a50103763b6e23b</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26191" 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/phoenix-v1-3-0-rc-0-released/3947/65">Post #64</a>
	                </div>
	            </div>
              <div id="likers-container-26191" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26191"
                     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 #64"></div>
  </section>
</div>
    <div class="postbit" id="26227" data-post-id="26227">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="rschooley" data-post="65" data-topic="3947">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/rschooley/48/4355_2.png" class="avatar"> rschooley:</div>
<blockquote>
<p>I wanted to a quick follow up of a possible approach I talked about.  Someone who is better at Elixir can probably make this better, but it shows a quick pass at it.</p>
</blockquote>
</aside>
<p>I believe the meta-programming suggestion and the original comment about having too many similar functions is missing the point that generator are guiding tools and they are not the end-goal of your design. For 3 resources in the same context, it is very unlikely that all of the functions will look like <code>list_comments</code>/<code>list_posts</code>/<code>lists_likes</code>. Rather a function like <code>list_comments</code> will end-up being <code>list_comments_per_post</code>, because it is unlikely you will want to list all comments in your domain but rather per post.</p>
<p>That’s exactly where your “use Foo.Model” idea breaks off. You will want to customize the generated code more often than not and relying on meta-programmed functions will only add indirection.</p>
<p>Finally I want to echo <a class="mention" href="/u/chrismccord" rel="nofollow">@chrismccord</a> in that we have extensively debated all of those topics, such as “should the changeset functions belong to the schema” and “will there be too many functions in the context”. We agree the jury is still out there but I believe the best way to answer those questions is by practicing them on long term applications. We have already been doing so and it ended-up that many of the concerns we had did not actually manifest with time. We will continue slightly refining the generators based on feedback.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26227" data-batch-url="/posts/batch_likers">
                        6
                      </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/phoenix-v1-3-0-rc-0-released/3947/66">Post #65</a>
	                </div>
	            </div>
              <div id="likers-container-26227" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26227"
                     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 #65"></div>
  </section>
</div>
    <div class="postbit" id="26232" data-post-id="26232">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="SupaSaya" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  SupaSaya
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>New to generators, when running:</p>
<pre><code>mix phx.gen.html Main Test tests proxy_id:references:main_proxies
</code></pre>
<p>Is it expected behavior that  “references” doesn’t create html fields?</p>
<p>../test/show.html.eex</p>
<pre><code>&lt;h2&gt;Show Test&lt;/h2&gt;

&lt;ul&gt;

&lt;/ul&gt;

&lt;span&gt;&lt;%= link "Edit", to: test_path(@conn, :edit, @test) %&gt;&lt;/span&gt;
&lt;span&gt;&lt;%= link "Back", to: test_path(@conn, :index) %&gt;&lt;/span&gt;
</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="26232" data-batch-url="/posts/batch_likers">
                        2
                      </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/phoenix-v1-3-0-rc-0-released/3947/67">Post #66</a>
	                </div>
	            </div>
              <div id="likers-container-26232" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26232"
                     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 #66"></div>
  </section>
</div>
    <div class="postbit" id="26235" data-post-id="26235">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, it is. Setting up references automatically can lead to wrong data being exposed or modified.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26235" data-batch-url="/posts/batch_likers">
                        4
                      </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/phoenix-v1-3-0-rc-0-released/3947/68">Post #67</a>
	                </div>
	            </div>
              <div id="likers-container-26235" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26235"
                     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 #67"></div>
  </section>
</div>
    <div class="postbit" id="26237" data-post-id="26237">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> Is authentication/ authorization an application or interface responsibility? In my opinion it would make much more sense to build it into the application’s api, as the app would then be self-contained and provide consistent functionality across interfaces.</p>
<pre><code>{:ok, token} = App.Auth.login(email, password)
{:ok, post} = App.Blog.create_post(token, attrs)
{:error, :unauthorized} = App.Admin.destroy_application(token)
App.Auth.logout(token)
{:error, :unauthenticated} = App.Blog.create_post(token, attrs)

## vs. ##

plug :ensure_authenticated
plug :ensure_authorized
{:ok, post} = App.Blog.create_post(user_id, attrs)
</code></pre>
<p>Also the approach that contexts shouldn’t know about other resources surpresses the use of Elixir’s pattern matching capabilities, is this an issue or a feature?</p>
<pre><code>App.Blog.create_post(user_id, attrs)

## vs ##

App.Blog.create_post(%App.Auth.User{}, attrs)
</code></pre>
<p>Edit: Better example</p>
<pre><code>App.Fleet.create_car_for_employee(employee_id, attrs)
App.Fleet.create_car_for_manager(manager_id, attrs)

## vs ##

App.Fleet.create_car(%App.HR.Employee{}, attrs)
App.Fleet.create_car(%App.HR.Manager{}, attrs)
</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="26237" data-batch-url="/posts/batch_likers">
                        2
                      </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/phoenix-v1-3-0-rc-0-released/3947/69">Post #68</a>
	                </div>
	            </div>
              <div id="likers-container-26237" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26237"
                     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 #68"></div>
  </section>
</div>
    <div class="postbit" id="26242" data-post-id="26242">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="zimt28" data-post="69" data-topic="3947">
<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><a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> Is authentication/ authorization an application or interface responsibility? In my opinion it would make much more sense to build it into the application’s api, as the app would then be self-contained and provide consistent functionality across interfaces.</p>
</blockquote>
</aside>
<p>Design it in your app and see what feels better. We are not going to arrive to conclusions based on pseudo-code. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="zimt28" data-post="69" data-topic="3947">
<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>Also the approach that contexts shouldn’t know about other resources surpresses the use of Elixir’s pattern matching capabilities, is this an issue or a feature?</p>
</blockquote>
</aside>
<p>A context can know about resources in other contexts, as long as those resources are explicitly returned by the context (i.e. as long as you respect the code boundaries).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26242" data-batch-url="/posts/batch_likers">
                        5
                      </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/phoenix-v1-3-0-rc-0-released/3947/70">Post #69</a>
	                </div>
	            </div>
              <div id="likers-container-26242" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26242"
                     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 #69"></div>
  </section>
</div>
    <div class="postbit" id="26374" data-post-id="26374">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Where would common “models” go? As an example, address model is the same and is shared by user, company, employee. What are the suggested alternatives for such a use case with the new paradigm? Love the new paradigm and thanks everyone on the elixir/phoenix team that help guide the community towards better ways. One way I can think of is to push it into a “communications” context and use it that way. Any other ideas that are better are welcome.</p>
<p>Also, where do models that cut across domains fit? Example, accounts has the user model (if I may still call it that). A company model lives somewhere. A user can belong to a company with a certain role. If we assume company is a different context (and not the accounts context), then role model (a users role within a company) fits where? - maybe in a new context called “user_roles”?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26374" data-batch-url="/posts/batch_likers">
                        2
                      </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/phoenix-v1-3-0-rc-0-released/3947/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-26374" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26374"
                     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 #71"></div>
  </section>
</div>
    <div class="postbit" id="26381" data-post-id="26381">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It is the same as in any other Elixir project. If you need to have functions or data structures that are shared across multiple contexts, you can define it at lib/my_app/foo.ex or lib/my_app/shared/foo.ex and just have everyone depend on it.</p>
<p>Btw, Phoenix does not have models from v1.3 and Ecto does not have models for a long while already. You probably meant to say schemas but remember schemas are simply data structures with type information attached to each field.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="26381" data-batch-url="/posts/batch_likers">
                        2
                      </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/phoenix-v1-3-0-rc-0-released/3947/73">Post #72</a>
	                </div>
	            </div>
              <div id="likers-container-26381" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="26381"
                     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 #72"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/3947/load_more?page=8">Load more posts (26 remaining)</a>
</div></template></turbo-stream>