[Rails] Re: self. vs. @
by Joshua Kolden other posts by this author
Aug 13 2007 12:14PM messages near this date
[Rails] Re: self. vs. @
|
[Rails] Re: self. vs. @
Thanks for your help. create_new_salt is only ever called from within
the the model object. Here is the only function that calls it:
def initialize(id, address, type)
@email = address
@type = type
@user_id = id
create_new_salt
self.key = self.encrypt_key(self.email, self.salt)
end
Perhaps I can't call it until after initialize has run? Also I still
don't understand why I should call self.salt in some of these cases
and not @salt.
Thanks,
j
On Aug 13, 11:55 am, "Vishnu Gopal" <g.vis...@[...].com> wrote:
> That code seems to be fine. Look at where create_new_salt is being
> called, it's probably being called on a nil Object instead of an AR
> model, possible a find condition returning nil instead of the
> model(s).
>
> Vish
>
> On 8/13/07, Joshua Kolden <crackcreat...@[...].com> wrote:
>
>
>
> > I'm working on an application that creates a confirmation e.mail
> > whenever you create and account or change an e.mail address. I
> > thought I'd just use the same key generation code used for the
> > password hash login example from the Agile Rails book.
>
> > The function to create a salt value keeps failing complaining I have a
> > nil object where I don't expect it.
>
> > The code where it breaks is:
>
> > def create_new_salt
> > self.salt = @user_id.to_s + rand.to_s
> > end
>
> > I've also put a constant string assigned to self.salt, but the error
> > still occurs, as if self.salt points to a nil object, but I don't see
> > how that can happen. I also don't understand any reason for this
> > function to call self.salt, instead of @salt. Any clues would be much
> > appreciated.
>
> > Thanks,
> > j
>
> > PS here is the table definition for this model.
>
> > :created_at, :timestamp
> > :email, :string
> > :type, :string #which of several e.mail columns in 'user' does this
> > change apply to
> > :user_id, integer
> > :key, :string #randomly generated key
> > :salt, :string
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Ta
lk" group.
To post to this group, send email to rubyonrails-talk@[...].com
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@[...].com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thread:
Joshua Kolden
Eric Anderson
Joshua Kolden
Eric Anderson
Vishnu Gopal
Joshua Kolden
Vishnu Gopal
Joshua Kolden
|