Automatically filling a text box

Well I am new to Rails and I’m looking to find out how to
automatically fill a text box with a randomly generated password. I
can generate and display the password just fine but I cannot find a
way to have the page load with the password already in the text field.

Regards,

Ryan

Hrmmm…

like in the controller, if it’s a User that has a password, you can’t
just do:

def new
@user = User.new
@user.password = ‘ryans_text’
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end

and have ‘ryans_text’ appear in the password field of the form???

Generally, you’ll not want passwords in a plain text_field… and a
password_field won’t show the text on purpose.

On 4/21/08, Ryan K. [email protected] wrote:

Well I am new to Rails and I’m looking to find out how to
automatically fill a text box with a randomly generated password. I
can generate and display the password just fine but I cannot find a
way to have the page load with the password already in the text field.

You can set it in the controller when you make a new instance of the
object:

@foo = Foo.new( :passwd => passwd )


Greg D.
http://destiney.com/

user form_for method

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs