Created
September 30, 2014 03:03
-
-
Save philwilt/1ca600332e5968bd95b6 to your computer and use it in GitHub Desktop.
comment on article code
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
# view/comments/_form.html.haml | |
= form_for(@comment) do |f| | |
- if @comment.errors.any? | |
#error_explaination | |
%h2= pluralize(@comment.errors.count, 'error') | |
%ul | |
- @comment.errors.full_message.each do |message| | |
%li= message | |
.field | |
= f.label :author | |
= f.text_field :author | |
.field | |
= f.label :author_email | |
= f.text_field :author_email | |
.field | |
= f.label :author_url | |
= f.text_field :author_url | |
.field | |
= f.label :content | |
= f.text_field :content | |
# ArticlesController.rb | |
#.... | |
def show | |
@comment = Comment::Comment.new | |
end | |
#.... | |
#view/articles/show.html.haml | |
%p | |
%strong Title: | |
= @article.title | |
%p#author | |
%b By: | |
= @article.author.email | |
%p | |
%strong Body: | |
= @article.body | |
.status | |
%b Status: | |
= @article.published? ? 'Published' : 'Unpublished' | |
- if policy(@article).edit? | |
= link_to 'Edit', edit_article_path(@article) | |
| | |
- if policy(@article).destroy? | |
= link_to 'Destroy', @article, method: :delete | |
= render 'comments/form' | |
= link_to 'Back', articles_path | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment