Ruby on Rails Sunday, July 29, 2012



On Friday, July 27, 2012 11:52:26 AM UTC+1, Sumit Srivastava wrote:


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?

It's hard to say because it's extremely hard to piece together what code exactly is excuting - seems like there's at least 3 different versions in this thread, but it sounds to me like you've
definte a password= method  always calls self.password= which (by definition) calls your password= method and so you end up in an infinite recursion.
The original tutorial you followed used a different name for the attribute so instead of calling self.password they were calling self.hashed_password= instead. You could either follow the tutorial (although as others have pointed it, it is really old (Rails 3.2has a has_secure_password that handles this) or use self.write_attribute(:password, some_value) when you want to store the hashed value


Fred
 
Regards
Sumit Srivastava

The power of imagination makes us infinite...


On 27 July 2012 16:12, Michael Pavling <pavling@gmail.com> wrote:
On 27 July 2012 11:37, sumit srivastava <sumit.theinvincible@gmail.com> wrote:
> 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])

I would put a breakpoint on that line and then keep stepping into
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
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.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Ed2oQol364oJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment