Skip to content

Instantly share code, notes, and snippets.

@avit
Created June 18, 2012 23:17
Show Gist options
  • Save avit/2951388 to your computer and use it in GitHub Desktop.
Save avit/2951388 to your computer and use it in GitHub Desktop.
Showing errors for a form partial
class ArticlesController < ActionController::Base
def show
@article = Article.find(params[:id])
# ... bunch of stuff to set up template display
end
end
class CommentsController < ActionController::Base
def create
post = Article.find(params[:article_id])
if @comment = articles.comments.create(params[:comment])
redirect_to article
else
# If validations fail, I need to display the original articles#show
# with the form showing @comment.errors
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment