Use One Function For Get And Put Actions
Join the DZone community and get the full member experience.Join For Free
This template enables you to use only one function to display a template and process it with the same one.
def new if request.get? # no post data, so create a new instance and render the template @post = Post.new else # post-part, form was filled out and we can save the post @post = Post.new(params[:post]) if @post.save flash[:notice] = 'Post was successfully created.' redirect_to :action => 'index' else render :action => 'new' end end end