Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
/public/assets
3 changes: 3 additions & 0 deletions app/assets/javascripts/boooooooks.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/boooooooks.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the boooooooks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
80 changes: 80 additions & 0 deletions app/controllers/boooooooks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class BoooooooksController < ApplicationController
# GET /boooooooks
# GET /boooooooks.json
def index
@boooooooks = Boooooook.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @boooooooks }
end
end

# GET /boooooooks/1
# GET /boooooooks/1.json
#def show
# @boooooook = Boooooook.find(params[:id])
#
# respond_to do |format|
# format.html # show.html.erb
# format.json { render json: @boooooook }
# end
# end

# GET /boooooooks/new
# GET /boooooooks/new.json
def new
@boooooook = Boooooook.new

respond_to do |format|
format.html # new.html.erb
end
end

# GET /boooooooks/1/edit
# def edit
# @boooooook = Boooooook.find(params[:id])
# end

# POST /boooooooks
# POST /boooooooks.json
def create
@boooooook = Boooooook.new(params[:boooooook])

if @boooooook.save
logger.debug boooooooks_index_url
#format.html { redirect_to @boooooook, notice: 'Boooooook was successfully created.' }
redirect_to boooooooks_index_url
else
render action: "new"
end
end

# PUT /boooooooks/1
# PUT /boooooooks/1.json
# def update
# @boooooook = Boooooook.find(params[:id])
#
# respond_to do |format|
# if @boooooook.update_attributes(params[:boooooook])
# format.html { redirect_to @boooooook, notice: 'Boooooook was successfully updated.' }
# format.json { head :no_content }
# else
# format.html { render action: "edit" }
# format.json { render json: @boooooook.errors, status: :unprocessable_entity }
# end
# end
# end

# DELETE /boooooooks/1
# DELETE /boooooooks/1.json
def destroy
@boooooook = Boooooook.find(params[:id])
@boooooook.destroy

respond_to do |format|
format.html { redirect_to boooooooks_index_url }
format.json { head :no_content }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/boooooooks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BoooooooksHelper
end
8 changes: 8 additions & 0 deletions app/models/boooooook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Boooooook < ActiveRecord::Base
attr_accessible :desc, :memo, :published


validates :desc, :presence => true, :length => {:maximum => 100}
validates :memo, :presence => true, :length => {:maximum => 100}

end
29 changes: 29 additions & 0 deletions app/views/boooooooks/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%= form_for(@boooooook) do |f| %>
<% if @boooooook.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@boooooook.errors.count, "error") %> prohibited this boooooook from being saved:</h2>

<ul>
<% @boooooook.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :desc %><br />
<%= f.text_area :desc %>
</div>
<div class="field">
<%= f.label :memo %><br />
<%= f.text_area :memo %>
</div>
<div class="field">
<%= f.label :published %><br />
<%= f.date_select :published %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/boooooooks/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing boooooook</h1>

<%= render 'form' %>

<%= link_to 'Show', @boooooook %> |
<%= link_to 'Back', boooooooks_path %>
25 changes: 25 additions & 0 deletions app/views/boooooooks/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h1>Listing boooooooks</h1>

<table>
<tr>
<th>Desc</th>
<th>Memo</th>
<th>Published</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @boooooooks.each do |boooooook| %>
<tr>
<td><%= boooooook.desc %></td>
<td><%= boooooook.memo %></td>
<td><%= boooooook.published %></td>
<td><%= link_to 'Destroy', 'boooooooks/' + boooooook.id.to_s, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Boooooook', 'boooooooks/new' %>
5 changes: 5 additions & 0 deletions app/views/boooooooks/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New boooooook</h1>

<%= render 'form' %>

<%= link_to 'Back', boooooooks_path %>
20 changes: 20 additions & 0 deletions app/views/boooooooks/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<p id="notice"><%= notice %></p>

<p>
<b>Desc:</b>
<%= @boooooook.desc %>
</p>

<p>
<b>Memo:</b>
<%= @boooooook.memo %>
</p>

<p>
<b>Published:</b>
<%= @boooooook.published %>
</p>


<%= link_to 'Edit', edit_boooooook_path(@boooooook) %> |
<%= link_to 'Back', boooooooks_path %>
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
BookMemo2::Application.routes.draw do
# resources :boooooooks
get '/boooooooks', :to => "boooooooks#index", :as => :boooooooks_index
post '/boooooooks', :to => "boooooooks#create"
get '/boooooooks/new', :to => "boooooooks#new", :as => :boooooooks_new
delete '/boooooooks/:id', :to => "boooooooks#destroy"
resources :books

# The priority is based upon order of creation:
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20120614125024_create_boooooooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateBoooooooks < ActiveRecord::Migration
def change
create_table :boooooooks do |t|
t.text :desc
t.text :memo
t.date :published

t.timestamps
end
end
end
10 changes: 9 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120526050801) do
ActiveRecord::Schema.define(:version => 20120614125024) do

create_table "books", :force => true do |t|
t.string "title"
Expand All @@ -21,4 +21,12 @@
t.datetime "updated_at", :null => false
end

create_table "boooooooks", :force => true do |t|
t.text "desc"
t.text "memo"
t.date "published"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

end
Loading