I have a form in which a bunch of new users can be created with the same
password if desired. I’m trying to write the password into the session
and pull it out in the controller (besides avoiding putting it into
params, this also should let me keep it for repopulating the text field
if the creation fails for any reason and the user gets sent back to the
page with the form).
As part of a form tag, i have this text field which is supposed to write
the value entered in it into the session
will create a textfield in html output (the browser does not know
anything about the rails session hash, anyway)
this will be handed to your controller as every other form data in
params[]
so params[:password] is the thing to use eg:
session[:new_user_password] = params[:password]
will create a textfield in html output (the browser does not know
anything about the rails session hash, anyway)
this will be handed to your controller as every other form data in
params[]
so params[:password] is the thing to use eg:
session[:new_user_password] = params[:password]
ah. cool, i’ve written the value from params into the session in the
controller and it’s fine now. thanks!
My interpretation of the feature is that you set as default the
password of the last created user.
If that was the case, you are done passing params[:password] for that
field no matter whether the creation of the user of that request is
successful or not. If the creation is successful that’s clear. If not
and the user edited the password and email validation failed you do
not want to set the default password back, you want to let him correct
the email and still set the password he chose, so params[:password]
makes sense there as well.
– fxn
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.