Retaining form values in Ruby on Rails -


i working on ror application , retain form values after form reloads on error server side user doesn't have go through filling form again.

this standard functionality, enabled use of @instance variable. allows send data ruby class (controller) , process returned data in single instance

you'd this:

#app/controllers/posts_controller.rb def new     @post = post.new #-> notice instance variable end  def create     @post = post.new(post_params)     @post.save end  private  def post_params     params.require(:post).permit(:title, :body) end 

this enables maintain instance of newly created activerecord object. means each time can't submit form, you'll receive errors inputted data


Comments

Popular posts from this blog

google app engine - 403 Forbidden POST - Flask WTForms -

Android layout hidden on keyboard show -

Parse xml element into list in Python -