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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
On 5/8/07, aveo
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> 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
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> 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, -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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, -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---