Skip to content
Browse files

more simplification

  • Loading branch information...
1 parent d79000f commit b987b42367b021ad478c082c65a1d94f5e5e84be @grobie committed Nov 10, 2009
View
3 app/views/comments/_comment.html.erb
@@ -0,0 +1,3 @@
+<p><strong><%= h comment.author %></strong> kommentierte am <%= comment.created_at.to_s(:short) %></p>
+<p><%= simple_format h(comment.content) %></p>
+<hr />
View
21 app/views/comments/_comments.html.erb
@@ -1,21 +0,0 @@
-<h3 id="comments"><%= pluralize @post.comments.size, "Kommentar", "Kommentare" %></h3>
-
-<% for comment in @post.comments %>
- <p><strong><%= h comment.author %></strong> kommentierte am <%= comment.created_at.to_s(:short) %></p>
- <p><%= simple_format h(comment.content) %></p>
- <hr />
-<% end %>
-
-<% form_for :comment, :url => post_comments_url(@post) do |f| %>
- <p>
- <%= f.label :author, "Autor" %><br />
- <%= f.text_field :author %>
- </p>
- <p>
- <%= f.label :content, "Kommentar" %><br />
- <%= f.text_area :content %>
- </p>
- <p>
- <%= f.submit "abschicken" %>
- </p>
-<% end %>
View
2 app/views/layouts/posts.html.erb
@@ -10,7 +10,7 @@
<body>
<div class="wrapper">
- <h1 class="title"><%= link_to "Mein Rails Blog", root_url %></h1>
+ <h1><%= link_to "Mein Rails Blog", root_url %></h1>
<p style="color: green"><%= flash[:notice] %></p>
<%= yield %>
View
3 app/views/posts/_post.html.erb
@@ -0,0 +1,3 @@
+<h2><%= link_to post.title, post %></h2>
+<div>geschrieben von <%=h post.author %> am <%= post.created_at.to_s(:short) %></div>
+<%= simple_format h(post.body) %>
View
9 app/views/posts/index.html.erb
@@ -1,11 +1,4 @@
-<% @posts.each do |post| %>
- <h2 class="post"><%= link_to post.title, post %></h2>
- <span>
- geschrieben von <%=h post.author %> am <%= post.created_at.to_s(:short) %>
- (<%= link_to pluralize(post.comments.size, "Kommentar", "Kommentare"), post_url(post, :anchor => "comments") %>)
- </span>
- <p><%=h post.body %></p>
-<% end %>
+<%= render :partial => "post", :collection => @posts %>
<br />
View
23 app/views/posts/show.html.erb
@@ -1,11 +1,22 @@
-<h2 class="post"><%=h @post.title %></h2>
-<span>geschrieben von <%=h @post.author %> am <%= @post.created_at.to_s(:short) %></span>
+<%= render :partial => @post %>
-<p>
- <%= simple_format h(@post.body) %>
-</p>
+<h3 id="comments"><%= pluralize @post.comments.size, "Kommentar", "Kommentare" %></h3>
+<%= render :partial => @post.comments %>
+
+<% form_for :comment, :url => post_comments_url(@post) do |f| %>
+ <p>
+ <%= f.label :author, "Autor" %><br />
+ <%= f.text_field :author %>
+ </p>
+ <p>
+ <%= f.label :content, "Kommentar" %><br />
+ <%= f.text_area :content %>
+ </p>
+ <p>
+ <%= f.submit "abschicken" %>
+ </p>
+<% end %>
-<%= render :partial => "comments/comments" %>
<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>
View
4 public/stylesheets/scaffold.css
@@ -8,13 +8,13 @@ div.wrapper {
padding: 20px;
}
-h1.title {
+h1 {
padding: 20px 0 40px;
margin: 0;
border-bottom: 1px solid black;
}
-h2.post {
+h2 {
margin: 30px 0 0;
padding-bottom: 0;
}

0 comments on commit b987b42

Please sign in to comment.
Something went wrong with that request. Please try again.