-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
391 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module Bawi | ||
class BoardsController < ApplicationController | ||
# GET /boards | ||
# GET /boards.json | ||
def index | ||
@boards = Board.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @boards } | ||
end | ||
end | ||
|
||
# GET /boards/1 | ||
# GET /boards/1.json | ||
def show | ||
@board = Board.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @board } | ||
end | ||
end | ||
|
||
# GET /boards/new | ||
# GET /boards/new.json | ||
def new | ||
@board = Board.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @board } | ||
end | ||
end | ||
|
||
# GET /boards/1/edit | ||
def edit | ||
@board = Board.find(params[:id]) | ||
end | ||
|
||
# POST /boards | ||
# POST /boards.json | ||
def create | ||
@board = Board.new(params[:board]) | ||
|
||
respond_to do |format| | ||
if @board.save | ||
format.html { redirect_to @board, notice: 'Board was successfully created.' } | ||
format.json { render json: @board, status: :created, location: @board } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @board.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /boards/1 | ||
# PUT /boards/1.json | ||
def update | ||
@board = Board.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @board.update_attributes(params[:board]) | ||
format.html { redirect_to @board, notice: 'Board was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @board.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /boards/1 | ||
# DELETE /boards/1.json | ||
def destroy | ||
@board = Board.find(params[:id]) | ||
@board.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to boards_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Bawi | ||
module BoardsHelper | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Bawi | ||
class Board < ActiveRecord::Base | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<%= form_for(@board) do |f| %> | ||
<% if @board.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@board.errors.count, "error") %> prohibited this board from being saved:</h2> | ||
|
||
<ul> | ||
<% @board.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :group_id %><br /> | ||
<%= f.number_field :group_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :user_id %><br /> | ||
<%= f.number_field :user_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :name %><br /> | ||
<%= f.text_field :name %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :keyword %><br /> | ||
<%= f.text_field :keyword %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :max_article_no %><br /> | ||
<%= f.number_field :max_article_no %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :max_comment_no %><br /> | ||
<%= f.number_field :max_comment_no %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :articles_count %><br /> | ||
<%= f.number_field :articles_count %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :comments_count %><br /> | ||
<%= f.number_field :comments_count %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :bookmarks_count %><br /> | ||
<%= f.number_field :bookmarks_count %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing board</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @board %> | | ||
<%= link_to 'Back', boards_path %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<h1>Listing boards</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Group</th> | ||
<th>User</th> | ||
<th>Name</th> | ||
<th>Keyword</th> | ||
<th>Max article no</th> | ||
<th>Max comment no</th> | ||
<th>Articles count</th> | ||
<th>Comments count</th> | ||
<th>Bookmarks count</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @boards.each do |board| %> | ||
<tr> | ||
<td><%= board.group_id %></td> | ||
<td><%= board.user_id %></td> | ||
<td><%= board.name %></td> | ||
<td><%= board.keyword %></td> | ||
<td><%= board.max_article_no %></td> | ||
<td><%= board.max_comment_no %></td> | ||
<td><%= board.articles_count %></td> | ||
<td><%= board.comments_count %></td> | ||
<td><%= board.bookmarks_count %></td> | ||
<td><%= link_to 'Show', board %></td> | ||
<td><%= link_to 'Edit', edit_board_path(board) %></td> | ||
<td><%= link_to 'Destroy', board, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Board', new_board_path %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New board</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', boards_path %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Group:</b> | ||
<%= @board.group_id %> | ||
</p> | ||
|
||
<p> | ||
<b>User:</b> | ||
<%= @board.user_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Name:</b> | ||
<%= @board.name %> | ||
</p> | ||
|
||
<p> | ||
<b>Keyword:</b> | ||
<%= @board.keyword %> | ||
</p> | ||
|
||
<p> | ||
<b>Max article no:</b> | ||
<%= @board.max_article_no %> | ||
</p> | ||
|
||
<p> | ||
<b>Max comment no:</b> | ||
<%= @board.max_comment_no %> | ||
</p> | ||
|
||
<p> | ||
<b>Articles count:</b> | ||
<%= @board.articles_count %> | ||
</p> | ||
|
||
<p> | ||
<b>Comments count:</b> | ||
<%= @board.comments_count %> | ||
</p> | ||
|
||
<p> | ||
<b>Bookmarks count:</b> | ||
<%= @board.bookmarks_count %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_board_path(@board) %> | | ||
<%= link_to 'Back', boards_path %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
Bawi::Engine.routes.draw do | ||
resources :groups | ||
resources :boards | ||
|
||
resources :groups do | ||
resources :boards | ||
end | ||
|
||
root to: "groups#index" | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class CreateBawiBoards < ActiveRecord::Migration | ||
def change | ||
create_table :bawi_boards do |t| | ||
t.integer :group_id, null: false, default: 0 | ||
t.integer :user_id, null: false | ||
t.string :name, null: false | ||
t.string :keyword, null: false | ||
t.integer :max_article_no, null: false, default: 0 | ||
t.integer :max_comment_no, null: false, default: 0 | ||
t.integer :articles_count, null: false, default: 0 | ||
t.integer :comments_count, null: false, default: 0 | ||
t.integer :bookmarks_count, null: false, default: 0 | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :bawi_boards, :group_id | ||
add_index :bawi_boards, [:user_id, :name] | ||
add_index :bawi_boards, :keyword, unique: true | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html | ||
|
||
one: | ||
group_id: 1 | ||
user_id: 1 | ||
name: MyString | ||
keyword: FirstBoard | ||
max_article_no: 0 | ||
max_comment_no: 0 | ||
articles_count: 0 | ||
comments_count: 0 | ||
bookmarks_count: 0 | ||
|
||
two: | ||
group_id: 1 | ||
user_id: 1 | ||
name: MyString | ||
keyword: SecondBoard | ||
max_article_no: 0 | ||
max_comment_no: 0 | ||
articles_count: 0 | ||
comments_count: 0 | ||
bookmarks_count: 0 |
Oops, something went wrong.