Skip to content

Commit

Permalink
전체공지, 자유게시판 삭제 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
k352ex committed Nov 21, 2015
1 parent af02547 commit 14b7348
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
6 changes: 6 additions & 0 deletions app/controllers/freeboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def update
end
end

def destroy
@freeboard = Freeboard.find(params[:id])
@freeboard.destroy
redirect_to freeboard_index_path
end


private

Expand Down
6 changes: 6 additions & 0 deletions app/controllers/notice_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def update
end
end

def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to notice_index_path
end

private

def post_params
Expand Down
8 changes: 4 additions & 4 deletions app/views/freeboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<%= render :partial => 'freeboard/freeboard' %>
</tbody>
</table>
<div class="pull-right">
<%= link_to("글 작성", new_freeboard_path, class: "btn btn-default", role: "button") %>
</div>

<%= link_to("글 작성", new_freeboard_path, class: "btn btn-default pull-right", role: "button") %>

<div class="text-center paginator">
<%= paginate @freeboard %>
<%= paginate @freeboard, :window => 2 %>
</div>
<div id="counter"class="pagination_count text-center">
<%= page_entries_info @freeboard, :remote => true %>
Expand Down
1 change: 1 addition & 0 deletions app/views/freeboard/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<% if current_user.id == @freeboard.user_id %>
<div class="pull-right">
<%= link_to("Edit", edit_freeboard_path(@freeboard), class: "btn btn-default") %>
<%= link_to("삭제", freeboard_path(@freeboard), class: "btn btn-default", method: :delete, data: { confirm: '정말로 삭제하시겠습니까?' }) %>
</div>
<% end %>
</div>
Expand Down
6 changes: 2 additions & 4 deletions app/views/notice/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
<%= render :partial => 'notice/post' %>
</tbody>
</table>
<div class="pull-right">
<%= link_to("글 작성", new_notice_path, class: "btn btn-default", role: "button") %>
</div>
<%= link_to("글 작성", new_notice_path, class: "btn btn-default pull-right", role: "button") %>
<div class="text-center paginator">
<%= paginate @post %>
<%= paginate @post, :window => 2 %>
</div>
<div id="counter"class="pagination_count text-center">
<%= page_entries_info @post, :remote => true %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/notice/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<%= raw @post.content %>
<% if current_user.id == @post.user_id %>
<div class="pull-right">
<%= link_to("Edit", edit_notice_path(@post), class: "btn btn-default") %>
<%= link_to("수정", edit_notice_path(@post), class: "btn btn-default") %>
<%= link_to("삭제", notice_path(@post), class: "btn btn-default", method: :delete, data: { confirm: '정말로 삭제하시겠습니까?' }) %>
</div>
<% end %>

Expand Down

0 comments on commit 14b7348

Please sign in to comment.