def password
#debugger
@password1=pass
self.salt = SecureRandom.hex(10) if !self.salt?
self.password = User.encrypt(@password1, self.salt)
end
SystemStackError (stack level too deep):
app/models/user.rb:26:in `password='
app/models/user.rb:27:in `password='
app/controllers/user_controller.rb:31:in `new'
app/controllers/user_controller.rb:31:in `createuser'
require 'digest/sha1'
class User < ActiveRecord::Base
attr_accessible :mailid, :name, :password, :username
validates:name, :presence=>true
validates:mailid, :presence=>true
validates:username, :presence=>true
validates:password, :presence=>true
validates_uniqueness_of :username, :mailid
validates_format_of :mailid, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid email"
attr_accessor :passwordtext
has_many :contacts
def self.hashedpass(login, pass)
u=find(:first, :conditions=>["login = ?", login])
return nil if u.nil?
return u if User.encrypt(pass, u.salt)==u.hashed_password
nil
end
def passwordtext=(pass)
#debugger
@password1=pass
self.salt = SecureRandom.hex(10) if !self.salt?
self.password = User.encrypt(@password1, self.salt)
end
def self.encrypt(pass, salt)
Digest::SHA1.hexdigest(pass+salt)
end
end
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Tom,
That might be another solution. But what I am trying to know is why isn't this method working. And how is the action def password=(pass) actually being called. Because I didn't see any exclusive line where it is being called. My analysis says it is being executed because of the attr_accessor and having name same as that of the column password.
Am I right?
Regards
Sumit Srivastava
The power of imagination makes us infinite...
On 27 July 2012 16:12, Michael Pavling <pav...@gmail.com> wrote:
On 27 July 2012 11:37, sumit srivastava <sumit.the...@gmail.com> wrote:I would put a breakpoint on that line and then keep stepping into
> This is what I receive,
>
> SystemStackError (stack level too deep):
> app/models/user.rb:26:in `password='
> app/models/user.rb:27:in `password='
> app/controllers/user_controller.rb:31:in `new'
> app/controllers/user_controller.rb:31:in `createuser'
>
> Here createuser action is used to store the user info into database.
>
> Line 31 reads as follows,
> @user = User.new(params[:user])
until you see where it's looping :-/
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
def password=(pass) @password=pass self.salt = User.random_string(10) if !self.salt? self.hashed_password = User.encrypt(@password, self.salt) end
def password=(pass)
@password1=pass
self.salt = SecureRandom.hex(10) if !self.salt?
self.password = User.encrypt(@password1, self.salt)
end
SystemStackError (stack level too deep):
> app/models/user.rb:26:in `password='
> app/models/user.rb:27:in `password='
> app/controllers/user_controller.rb:31:in `new'
> app/controllers/user_controller.rb:31:in `createuser'
>
def passwordtext=(pass)
@password1=pass
self.salt = SecureRandom.hex(10) if !self.salt?
self.password = User.encrypt(@password1, self.salt)
end
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Ed2oQol364oJ.To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
So I updated the method as follows,def passwordtext=(pass)
@password1=pass
self.salt = SecureRandom.hex(10) if !self.salt?
self.password = User.encrypt(@password1, self.salt)
end
And added a attr_accessor named as passwordtext. Also I renamed the password_field_tag in the view as "passwordtext". Doing this didn't help at all as the passwordtext method didn't execute.
So, the problem how should I rename my variables to make it work.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ciXDKwGTLKQJ.To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.