Created
June 18, 2012 23:17
-
-
Save avit/2951388 to your computer and use it in GitHub Desktop.
Showing errors for a form partial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ActionController::Base | |
def show | |
@article = Article.find(params[:id]) | |
# ... bunch of stuff to set up template display | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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