-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
c67d64a
commit 3b81308
Showing
32 changed files
with
564 additions
and
296 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
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,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/ |
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,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/ |
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,3 @@ | ||
// Place all the styles related to the Categories controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,3 @@ | ||
// Place all the styles related to the Notes controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,69 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; | ||
} | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; | ||
} | ||
} | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
} |
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,3 +1,10 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
|
||
|
||
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found | ||
|
||
def record_not_found | ||
render json: {:error => "Unable to find item"} , status: :unprocessable_entity | ||
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,83 @@ | ||
class CategoriesController < ApplicationController | ||
# GET /categories | ||
# GET /categories.json | ||
def index | ||
@categories = Category.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @categories } | ||
end | ||
end | ||
|
||
# GET /categories/1 | ||
# GET /categories/1.json | ||
def show | ||
@category = Category.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @category } | ||
end | ||
end | ||
|
||
# GET /categories/new | ||
# GET /categories/new.json | ||
def new | ||
@category = Category.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @category } | ||
end | ||
end | ||
|
||
# GET /categories/1/edit | ||
def edit | ||
@category = Category.find(params[:id]) | ||
end | ||
|
||
# POST /categories | ||
# POST /categories.json | ||
def create | ||
@category = Category.new(params[:category]) | ||
|
||
respond_to do |format| | ||
if @category.save | ||
format.html { redirect_to @category, notice: 'Category was successfully created.' } | ||
format.json { render json: @category, status: :created, location: @category } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @category.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /categories/1 | ||
# PUT /categories/1.json | ||
def update | ||
@category = Category.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @category.update_attributes(params[:category]) | ||
format.html { redirect_to @category, notice: 'Category was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @category.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /categories/1 | ||
# DELETE /categories/1.json | ||
def destroy | ||
@category = Category.find(params[:id]) | ||
@category.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to categories_url } | ||
format.json { head :no_content } | ||
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,92 @@ | ||
class NotesController < ApplicationController | ||
|
||
before_filter :load_category | ||
|
||
# GET /notes | ||
# GET /notes.json | ||
def index | ||
@notes = @category.notes.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @notes } | ||
end | ||
end | ||
|
||
# GET /notes/1 | ||
# GET /notes/1.json | ||
def show | ||
@note = Note.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @note } | ||
end | ||
end | ||
|
||
# GET /notes/new | ||
# GET /notes/new.json | ||
def new | ||
@note = @category.notes.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @note } | ||
end | ||
end | ||
|
||
# GET /notes/1/edit | ||
def edit | ||
@note = Note.find(params[:id]) | ||
end | ||
|
||
# POST /notes | ||
# POST /notes.json | ||
def create | ||
@note = @category.notes.new(params[:note]) | ||
|
||
respond_to do |format| | ||
if @note.save | ||
format.html { redirect_to category_notes_path, notice: 'Note was successfully created.' } | ||
format.json { render json: @note, status: :created, location: @note } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @note.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /notes/1 | ||
# PUT /notes/1.json | ||
def update | ||
@note = Note.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @note.update_attributes(params[:note]) | ||
format.html { redirect_to @note, notice: 'Note was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @note.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /notes/1 | ||
# DELETE /notes/1.json | ||
def destroy | ||
@note = Note.find(params[:id]) | ||
@note.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to notes_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
|
||
private | ||
def load_category | ||
@category = Category.find(params[:category_id]) | ||
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,2 @@ | ||
module CategoriesHelper | ||
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,2 @@ | ||
module NotesHelper | ||
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,5 @@ | ||
class Category < ActiveRecord::Base | ||
attr_accessible :description, :name, :title | ||
has_many :notes | ||
|
||
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,5 @@ | ||
class Note < ActiveRecord::Base | ||
attr_accessible :description, :name, :title | ||
|
||
belongs_to :category | ||
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,29 @@ | ||
<%= form_for(@category) do |f| %> | ||
<% if @category.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from being saved:</h2> | ||
|
||
<ul> | ||
<% @category.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :name %><br /> | ||
<%= f.text_field :name %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :title %><br /> | ||
<%= f.text_field :title %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :description %><br /> | ||
<%= f.text_area :description %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
Oops, something went wrong.