/journeys 539 > script/console Loading development environment (Rails 2.1.1) >> user = User.find(:first) => #<User id: 1, username: "Admin", email: "[EMAIL PROTECTED]", hashed_password: "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81...", enabled: true, profile: "Site Administrator", created_at: "2008-09-21 07:06:44", updated_at: "2008-09-23 10:31:52", last_login_at: nil, posts_count: 0, entries_count: 0, blog_title: "Big Kahuna", enable_comments: true, photos_count: nil> >> exit /journeys 540 >
On Oct 27, 3:05 am, Soh Dubom <[EMAIL PROTECTED]> wrote: > 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 viahttp://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 -~----------~----~----~----~------~----~------~--~---

