How to restore fields ("validates_presence_of")

Hi all,
I am using “validates_presence_of” for validating all fields of my
registration form. It is working fine and generating custom error
message as mentioned.
Also clearing all fields. How can restore those fields which are already
filled.
Problem is “validates_presence_of” clearing (blank) field if it fails,
instead of restoring fields which are already filled.
Help.

Thanks

I believe reloading fields is handled in the controller action for
create, scaffolding builds a create method like:
create
@request = Request.new(params[:request])
if @request.save
flash[:notice] = ‘Request was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

the line
@request = Request.new(params[:request])
should reload the submitted values.

Seth

create, scaffolding builds a create method like:
create
@request = Request.new(params[:request])
if @request.save
flash[:notice] = ‘Request was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

the line
@request = Request.new(params[:request])
should reload the submitted values.

Yes, I am doing in same way, but can not happen. User has to again, fill
all fields, Please suggest if any thing wrong goes.
my controller
##############
def create
#@met = Met.new(@params[‘met’])
@met = Met.new(params[:met])
if @met.save
session[:user] = @met.id
redirect_to :controller =>‘project’, :action => ‘proj’, :id =>
@met.id
else
render_action ‘new’
end
end
########################

Thanks,

def create
#@met = Met.new(@params[‘met’])
@met = Met.new(params[:met])
if @met.save
session[:user] = @met.id
redirect_to :controller =>‘project’, :action => ‘proj’, :id =>
@met.id
else
render_action ‘new’
end
end
########################

Thanks,

Same code works for update module, and restore the fields.
########################
def update
@met = Met.find(params[:id])
@met.save
if @met.update_attributes(params[:met])
redirect_to :controller =>‘project’, :action => ‘proj’, :id =>
@met.id
else
render_action ‘edit’
end
end
##############################
But not for create ,
Please help me out.

Thanks,

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