How to retrieve console input in a ruby class
Hi. Suppose I have a db table 'users': username, password, email etc and
a ruby class User. In the rails console I type:
u = User.new
u.password = '123'
...
u.save
>From inside the user.rb class, how can I request the user attributes
like password?
At this point I don't have the the view done so I not considering I'm
getting user input through a web form. In this case I can get user input
through the @password keyword, but what about the other case?
In the before_create I could do that
def before_create
self.password = User.hash_password(@password)
end
but that will work only for web form submit!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---