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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Does anyone know where I can find an up to date version of the source code?</p>
<p>I bought this book from the PragProg website and downloaded the source code from there too. Unfortunately, the code blocks in the book do not match up with provided code, looks like it’s for an old version.</p>
<p>Edit: Made it all the way to chapter 9 without realising the file paths above the code blocks are links to the source <img src="https://forum.elixirforum.com/images/emoji/apple/roll_eyes.png?v=15" title=":roll_eyes:" class="emoji" alt=":roll_eyes:" 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="170530" 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/programming-phoenix-pragprog/5883/54">Post #53</a>
	                </div>
	            </div>
              <div id="likers-container-170530" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="170530"
                     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 #53"></div>
  </section>
</div>
    <div class="postbit" id="171091" data-post-id="171091">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello everyone,</p>
<p>I don’t know if this is the right place to question about some code of the book so if Im at the wrong place just let me know. here I go</p>
<p>At chapter 4 (Esto), user struct is modified into this</p>
<p>“defmodule​ Rumbl.Accounts.User ​do​<br>
​ 	  ​use​ Ecto.Schema<br>
​ 	  ​import​ Ecto.Changeset<br>
​ 	<br>
​ 	  schema ​"​​users"​ ​do​<br>
​ 	    field ​:name​, ​:string​<br>
​ 	    field ​:username​, ​:string​<br>
​ 	<br>
​ 	    timestamps()<br>
​ 	  ​end​<br>
​ 	​end​”</p>
<p>then a code is generated with the sentence ​​-&gt; mix​​ ​​ecto.gen.migration​​ ​​create_users​</p>
<p>The file generated in my case was almost empty<br>
defmodule Rumbl.Repo.Migrations.CreateUsers do<br>
use Ecto.Migration</p>
<p>def change do</p>
<p>end<br>
end</p>
<p>My question is, was the code well generated? and is my duty edit it and make it into this(just as appears in the book)</p>
<p>defmodule Rumbl.Repo.Migrations.CreateUsers do<br>
use Ecto.Migration</p>
<p>def change do<br>
create table(:users) do<br>
add :name, :string<br>
add :username, :string<br>
add :password_hash, :string</p>
<pre><code>  timestamps()
end

create unique_index(:users, [:username])
</code></pre>
<p>end<br>
end</p>
<p>I still don’t get if the sentence → mix​​ ​​ecto.gen.migration​​ ​​create_users​ really generate the migration file with the add sentences and timestamp or if it just creates the skeleton just like it did in my case.</p>
<p>Thanks in advance to anyone and I hope you can give me a hand. I’m really excited reading this book.</p>
<p>regards</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171091" 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/programming-phoenix-pragprog/5883/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-171091" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171091"
                     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 #54"></div>
  </section>
</div>
    <div class="postbit" id="171096" data-post-id="171096">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>it is your duty to fill out the migration.  It seems strange to have to write almost the same code twice, but soon you will start writing schema that don’t look like migrations (for example containing UX elements), or multiple different schemas for the same table (one for business logic and one for UX) etc.</p>
<p>Also generally speaking, in phoenix, except for the really low level stuff like handling http connections, parsing headers, etc, if you don’t see the code that does something, it’s not there.  The macros do sprinkle magic in there, but the magic that gets sprinkled is more or less “opinionated code organization”.  It took me a while to understand this and learn how to follow the macros to find the things, but I spent a lot of angst worrying that it was like RoR.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171096" 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/programming-phoenix-pragprog/5883/56">Post #55</a>
	                </div>
	            </div>
              <div id="likers-container-171096" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171096"
                     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 #55"></div>
  </section>
</div>
    <div class="postbit" id="171098" data-post-id="171098">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m certainly no expert on Phoenix, but I did go through that chapter recently.</p>
<p>My understanding is that <code>mix​​ ​​ecto.gen.migration​​ ​​create_users</code> will only generate the skeleton of the migration. You would then fill out the <code>schema</code> section and run <code>mix ecto.migrate</code> to apply the changes to the database.</p>
<p>I believe the authors’ intentions were to show how to not rely exclusively on generators, which are later presented in Chapter 6. For instance, one command seen later on <code>mix phx.gen.html Multimedia Video videos user_id:references:users url:string title:string description: test</code> generates several files, including a more fleshed out migration based on the inputs provided for the command.</p>
<p>Hopefully I didn’t butcher any explanation too badly, but that should be the gist… Hope that helps!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171098" 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/programming-phoenix-pragprog/5883/57">Post #56</a>
	                </div>
	            </div>
              <div id="likers-container-171098" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171098"
                     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 #56"></div>
  </section>
</div>
    <div class="postbit" id="171161" data-post-id="171161">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the explanation. I just wanted to be sure and follow to next charters with solid foundations (trying it at least]</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171161" 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/programming-phoenix-pragprog/5883/58">Post #57</a>
	                </div>
	            </div>
              <div id="likers-container-171161" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171161"
                     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 #57"></div>
  </section>
</div>
    <div class="postbit" id="171162" data-post-id="171162">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for your reply it really helped me. As I wrote before I’m trying to go further in the books but with “solid” foundations and really understand the frameworks and the philosophy.</p>
<p>Thanks again for your help</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171162" 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/programming-phoenix-pragprog/5883/59">Post #58</a>
	                </div>
	            </div>
              <div id="likers-container-171162" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171162"
                     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 #58"></div>
  </section>
</div>
    <div class="postbit" id="171627" data-post-id="171627">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello again guys,</p>
<p>This time I bring some questions regarding the charter 5 (authentication) I hope you could help to figure then out.</p>
<ol>
<li>
<p>Is the changes function (created at chapter 4) being used (called) in the registration_changeset function? if that’s true is the function cast being invoked 2 times? would be better (for performance at very low low level) just create registration_changeset function without using the changeset function and obviously putting its logic in the registration_changeset function?</p>
</li>
<li>
<p>There is a point in the book where are updated all the users already presents in DB adding a password. why if all the passwords are being created using the same key the password_hash stored in DB is different in all cases/users?</p>
</li>
<li>
<p>is correct the password_hash store in DB would be like this ‘$pbkdf2-sha512$160000$p1reFOXMlI1K1qplSHlNNg$/TLJ6ffDICFlwcvFkc0awRBkJXsV6d/DUYoy5QEv/PUAVLgM1kdt2qZQDhzoCck9pEm.gFeLltfx04qSi7SYlg’? including $pbkdf2-sha512$160000$ at the beginning of each one</p>
</li>
<li>
<p>The final implementation of create function on user_controller</p>
</li>
</ol>
<pre data-code-wrap="def"><code class="lang-def">    #antes del cambio
    #case Accounts.create_user(user_params) do
    case Accounts.register_user(user_params) do
      {:ok, user} -&gt;
        conn
        |&gt; RumblWeb.Auth.login(user)
        |&gt; put_flash(:info, "#{user.name} created!")
        |&gt; redirect(to: Routes.user_path(conn, :index))

      {:error, %Ecto.Changeset{} = changeset} -&gt;
        render(conn, "new.html", changeset: changeset)
    end
  end
type or paste code here
</code></pre>
<blockquote>
<p>throws a warning calling RumblWeb.Auth.login function saying<br>
RumblWeb.Auth.login/2</p>
<p>is undefined or private<br>
why?</p>
</blockquote>
<ol start="5">
<li>
<p>Supposed I have several controllers and all of them needs user authentication, what would be the best way to use the authentication plug cross controller? in the route pipeline? How?</p>
</li>
<li>
<p>Why the authentication plug was developed in the controller folder because as far as I understood is not a controller, in fact wonder why the login function was located in that module instead of being located anywhere else, maybe because it fits better in the controller layer?</p>
</li>
</ol>
<p>Sorry for being so annoying, and thanks in advance to all of you</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171627" 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/programming-phoenix-pragprog/5883/60">Post #59</a>
	                </div>
	            </div>
              <div id="likers-container-171627" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171627"
                     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 #59"></div>
  </section>
</div>
    <div class="postbit" id="171653" data-post-id="171653">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here’s my take on some of the questions. Again, keep in mind I am no expert in Phoenix:</p>
<ol>
<li>
<p>I’m not knowledgeable about the performance implications, but this proposed approach could get messy with excessive code duplication once functionality beyond the book is introduced. For instance, if you wanted to add a “change password” functionality then you’d duplicate the contents of <code>changeset</code> again.</p>
</li>
<li>
<p>In this situation, the same passwords are being used across all accounts… so if we were to hash just the password itself, we should indeed get the same hashes for each user. However, in addition to the password, we also add a random salt (of a consistent length) to the password before hashing. This salt is what causes a different result for each entry. Salting is a standard technique and can help guard against attacks like rainbow tables.</p>
</li>
<li>
<p>I believe this is fine and correct. From what I gather, the technique used to generate the password is simply being prepended along with the number of iterations. This is not uncommon and can be useful if you ever need to change how you process a password in the future.</p>
</li>
<li>
<p>I did not get this warning earlier this week… could there be a typo somewhere causing it?</p>
</li>
<li>
<p>I’m not sure if there is a better place than the route pipeline for the Auth plug, but it seems to generalize well in that location later on in the book.</p>
</li>
<li>
<p>I don’t have enough exposure to Phoenix to provide advice here.</p>
</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="171653" 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/programming-phoenix-pragprog/5883/61">Post #60</a>
	                </div>
	            </div>
              <div id="likers-container-171653" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171653"
                     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 #60"></div>
  </section>
</div>
    <div class="postbit" id="231636" data-post-id="231636">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Will this book be updated for Phoenix 1.6?<br>
<a class="mention" href="/u/pragprog" rel="nofollow">@pragprog</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="231636" 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/programming-phoenix-pragprog/5883/62">Post #61</a>
	                </div>
	            </div>
              <div id="likers-container-231636" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="231636"
                     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 #61"></div>
  </section>
</div>
    <div class="postbit" id="240179" data-post-id="240179">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hello everybody!</p>
<p><a class="mention" href="/u/pragprog" rel="nofollow">@pragprog</a> <a class="mention" href="/u/chrismccord" rel="nofollow">@chrismccord</a> <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> <a class="mention" href="/u/redrapids" rel="nofollow">@redrapids</a> Hey guys! Thanks for this great book! Do you know if it will be updated to latest Phoenix 1.6 (or even maybe the next one 1.7) since some important things changed (gen_auth, LiveView, heex, etc.)</p>
<p>Also, hijacking this comment to ask the following.. I noticed the “XYZ Brain Teasers” series. Please guys do one with Elixir (also <a class="mention" href="/u/sasajuric" rel="nofollow">@sasajuric</a>)!</p>
<p>It was delightful to watch José in AoC.. I guess an Elixir Brain Teasers will be a best seller!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="240179" data-batch-url="/posts/batch_likers">
                        3
                      </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/programming-phoenix-pragprog/5883/63">Post #62</a>
	                </div>
	            </div>
              <div id="likers-container-240179" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="240179"
                     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>
</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/5883/load_more?page=7">Load more posts (8 remaining)</a>
</div></template></turbo-stream>