<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'self vs. @' | Pragmatic Forums</title>
    <link>http://fora.pragprog.com/forums/22/topics/217</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>self vs. @ posted by Paul Jewell @ Sun, 24 Feb 2008 07:32:54 -0000</title>
      <description>&lt;p&gt;It doesn&amp;#8217;t have preview, but it does allow you to edit the post. I had the same thought posting a message in a different area, but luckily spotted the edit button next to the avatar :-)&lt;/p&gt;</description>
      <pubDate>Sun, 24 Feb 2008 07:32:54 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:22:217:2324</guid>
      <author>Paul Jewell</author>
      <link>http://fora.pragprog.com/forums/22/topics/217</link>
    </item>
    <item>
      <title>self vs. @ posted by Russell Healy @ Thu, 17 Jan 2008 00:25:11 -0000</title>
      <description>&lt;p&gt;Ugh, sorry about the formatting. I wish this forum had a preview!&lt;/p&gt;</description>
      <pubDate>Thu, 17 Jan 2008 00:25:11 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:22:217:2178</guid>
      <author>Russell Healy</author>
      <link>http://fora.pragprog.com/forums/22/topics/217</link>
    </item>
    <item>
      <title>self vs. @ posted by Russell Healy @ Thu, 17 Jan 2008 00:22:08 -0000</title>
      <description>&lt;p&gt;I suppose that &lt;code&gt;self.salt = ...&lt;/code&gt; is used so that the method generated by rails is called, rather than assigning to the instance variable, which would be making an assumption about the rails implementation. In fact, if you inspect the user (with user.inspect) you will see that rails doesn&amp;#8217;t even create an instance variable called @salt. Instead, all of the attributes generated by inspecting the database schema are put in a hash called attributes:&lt;/p&gt;


&lt;h1&gt;&amp;lt;user:0xb69384cc&gt;&amp;#8220;123&amp;#8221;, &amp;#8220;name&amp;#8221;=&amp;gt;&amp;#8221;benjamin&amp;#8221;, &amp;#8220;hashed_password&amp;#8221;=&amp;gt;&amp;#8221;a335e63a110911315788dbe5b1d44815bdd528ae&amp;#8221;, &amp;#8220;id&amp;#8221;=&amp;gt;2}&lt;/h1&gt;




	&lt;p&gt;The accessor method &amp;#8216;salt&amp;#8217; must retrieve the value from the @attributes hash.&lt;/p&gt;


	&lt;p&gt;That doesn&amp;#8217;t explain though, the use of self.password and self.salt in the line on page 158:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;self.hashed_password = User.encrypted_password(self.password, self.salt)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The following should be sufficient:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;self.hashed_password = User.encrypted_password(password, salt)&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Thu, 17 Jan 2008 00:22:08 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:22:217:2177</guid>
      <author>Russell Healy</author>
      <link>http://fora.pragprog.com/forums/22/topics/217</link>
    </item>
    <item>
      <title>self vs. @ posted by Barry Simpson @ Sun, 13 Jan 2008 20:38:59 -0000</title>
      <description>&lt;p&gt;I need some clarification on page 157 (2nd edition)&amp;#8212;probably because I&amp;#8217;m a newbie to both Ruby and Rails.&lt;/p&gt;


	&lt;p&gt;In the create_new_salt method, why wouldn&amp;#8217;t you use &lt;code&gt;@salt&lt;/code&gt; instead of &lt;code&gt;self.salt&lt;/code&gt;? Don&amp;#8217;t those mean the same thing? The text says you wouldn&amp;#8217;t want to use &lt;code&gt;salt = &lt;/code&gt; because Ruby would think you were referring to a local variable. That much is obvious to me already. But why wouldn&amp;#8217;t you use &lt;code&gt;@salt = &lt;/code&gt;, like most other places in the book, to assign to the instance variable?&lt;/p&gt;


	&lt;p&gt;Loving the book, by the way.&lt;/p&gt;</description>
      <pubDate>Sun, 13 Jan 2008 20:38:59 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:22:217:2165</guid>
      <author>Barry Simpson</author>
      <link>http://fora.pragprog.com/forums/22/topics/217</link>
    </item>
  </channel>
</rss>
