Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ruseel/rboard
base: 4bf994ba86
...
head fork: ruseel/rboard
compare: 64b58ad308
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
View
32 app/assets/stylesheets/rboard.css.scss
@@ -2,10 +2,32 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
-.rboard th.subject {
- width: 80%;
+.rboard {
+ th.subject {
+ width: 80%;
+ }
+
+ .table td {
+ white-space: nowrap;
+ }
+
+ .article {
+ margin: 20px 0;
+ }
+
+ .actions {
+ margin: 20px 0 40px;
+ }
+
+ .comments {
+ form {
+ textarea#comment_body {
+ height: 5em;
+ }
+ .btn {
+ vertical-align: top;
+ }
+ }
+ }
}
-.rboard .table td {
- white-space: nowrap;
-}
View
16 app/controllers/comments_controller.rb
@@ -1,23 +1,25 @@
# vim: set fileencoding=utf-8 :
class CommentsController < ApplicationController
- # def index
- # @comments = Comment.all
- # end
+
+ before_filter :set_board
+
+ def set_board
+ @board = Board.where(id: params[:board_id]).first
+ end
+
def show
@comment = Comment.find(params[:id])
end
- # def new
- # end
-
def create
@topic = Topic.find(params[:topic_id])
+ @board = @topic.board
@comment = Comment.new(params[:comment])
@comment.topic = @topic
if @topic && @comment.save
- redirect_to [@board, @topic]
+ redirect_to [@topic.board, @topic]
else
flash[:notice] = "empty body"
@comments = @topic.comments
View
2  app/controllers/topics_controller.rb
@@ -7,6 +7,7 @@ def set_board
@board = Board.where(id: params[:board_id]).first
end
+
def index
@topics = @board.topics.page(params[:page])
end
@@ -23,6 +24,7 @@ def new
def create
@topic = Topic.new(params[:topic])
+ @topic.board = @board
if params[:parent_id].present?
@topic.parent = Topic.find(params[:parent_id])
end
View
4 app/views/comments/_form.html.erb
@@ -1,5 +1,5 @@
<%= form_for @comment do |f| %>
<%= hidden_field_tag :topic_id, @comment.topic.id %>
- <%= f.text_area :body %>
- <%= f.submit "댓글 적기" %>
+ <%= f.text_area :body, class: "span9" %>
+ <%= f.submit "댓글 적기", class: "btn " %>
<% end %>
View
2  app/views/topics/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for @topic do |f| %>
+<%= form_for [@board,@topic] do |f| %>
<% if @topic.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@topic.errors.count, "error") %> prohibited this topic from being saved:</h2>
View
8 app/views/topics/index.html.erb
@@ -10,12 +10,12 @@
<% @topics.each do |topic| %>
<tr>
<td>
- <%= link_to (depth_mark(topic.depth) + topic.subject), topic %>
+ <%= link_to (depth_mark(topic.depth) + topic.subject), [topic.board, topic] %>
</td>
<td><%= topic.created_at %></td>
<td>
- <%= link_to "보기", topic %>
- <%= link_to "수정", edit_topic_path(topic) %>
+ <%= link_to "보기", [topic.board,topic] %>
+ <%= link_to "수정", edit_board_topic_path(topic.board, topic) %>
</td>
</tr>
<% end %>
@@ -24,6 +24,6 @@
<%= paginate @topics %>
<div class="footer">
- <%= link_to "새글 작성", new_topic_path %>
+ <%= link_to "새글 작성", new_board_topic_path(@board) %>
</div>
</div>
View
42 app/views/topics/show.html.erb
@@ -1,26 +1,28 @@
-<div class="article">
- <div class="subject">
- 제목: <%= @topic.subject %>
+<div class="rboard">
+ <div class="article">
+ <h1><%= @topic.subject %></h1>
+ <hr>
+ <div class="body">
+ <%= @topic.body %>
+ </div>
</div>
- <div class="body">
- <%= @topic.body %>
+
+ <div class="actions">
+ <%= link_to "답글", new_board_topic_path(@board, parent_id: @topic.id) %>
+ <%= link_to "목록", board_topics_path(@board) %>
</div>
-</div>
-<div class="comments">
- <% flash.each do |k, v| %>
- <div class="flash <%= k %>"><%= v %></div>
- <% end %>
- <ul>
- <% @comments.each do |c| %>
- <li><%= c.body %></li>
- <% end %>
- </ul>
- <%= render partial: "comments/form", object: @new_comment %>
-</div>
+ <div class="comments">
+ <%= render partial: "comments/form", object: @new_comment %>
-<div class="actions">
- <%= link_to "답글", new_topic_path(parent_id: @topic.id) %>
- <%= link_to "목록", topics_path %>
+ <% flash.each do |k, v| %>
+ <div class="flash <%= k %>"><%= v %></div>
+ <% end %>
+ <ul>
+ <% @comments.each do |c| %>
+ <li><%= c.body %></li>
+ <% end %>
+ </ul>
+ </div>
</div>
View
1  test/fixtures/topics.yml
@@ -3,6 +3,7 @@
one:
subject: fixture_one
body: body of one
+ board: one
topic_belongs_to_board_two:
subject: topic_belongs_to_board_two
View
3  test/functional/comments_controller_test.rb
@@ -2,6 +2,7 @@
class CommentsControllerTest < ActionController::TestCase
setup do
+ @board = boards(:one)
@comment = comments(:one)
@topic = topics(:one)
end
@@ -17,7 +18,7 @@ class CommentsControllerTest < ActionController::TestCase
post :create, comment: { body: "comment" }, topic_id: @topic
end
- assert_redirected_to @topic
+ assert_redirected_to [@topic.board, @topic]
end
test "should show flash for empty body" do
View
1  test/functional/topics_controller_test.rb
@@ -59,6 +59,7 @@ class TopicsControllerTest < ActionController::TestCase
test "should create reply" do
reply = topics(:reply)
post :create, topic: { subject: reply.subject, body: reply.body }, parent_id: @topic, board_id: @board
+ assert_equal @board, assigns(:topic).board
assert_equal @topic.boardish.inc_at_depth(1), assigns(:topic).boardish
end
end
View
2  test/integration/board_flow_test.rb
@@ -7,6 +7,6 @@ class BoardFlowTest < ActionDispatch::IntegrationTest
test "get url topics of boards(:one) " do
get board_topics_path(boards(:one))
- assert_equal 0, assigns(:topics).size
+ assert_equal 1, assigns(:topics).size
end
end

No commit comments for this range

Something went wrong with that request. Please try again.