parent
5a74813ce4
commit
e57c97bf3b
@ -1,28 +1,60 @@
|
||||
== README
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
|
||||
Things you may want to cover:
|
||||
|
||||
* Ruby version
|
||||
|
||||
* System dependencies
|
||||
|
||||
* Configuration
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
||||
|
||||
|
||||
Please feel free to use a different markup language if you do not plan to run
|
||||
<tt>rake doc:app</tt>.
|
||||
# API Docs
|
||||
|
||||
## Classical
|
||||
|
||||
User + Session are all done the 'old fashioned way' via server-rendered erb.
|
||||
|
||||
ROOT (/): Renders the Sign In / Sign Up forms.
|
||||
POST /users will create a new user, redirect to ROOT
|
||||
POST /session will create a new session, redirect to SPA page
|
||||
|
||||
---
|
||||
## JSON
|
||||
|
||||
GET /current_user will return JSON object containing currently logged in user
|
||||
|
||||
GET /transgressions will return array of transgressions complete with confessions subarray
|
||||
|
||||
```json
|
||||
{
|
||||
transgressions: [
|
||||
{
|
||||
id: 3,
|
||||
sin_type: "Gluttony",
|
||||
description: "I love eating a whole box full of cucumbers, like a 20lb box"
|
||||
confessions: [
|
||||
{
|
||||
description: "Some description",
|
||||
occurred_at: "3 weeks ago"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
POST /transgressions will take a JSON object as such:
|
||||
|
||||
```json
|
||||
{
|
||||
authenticity_token: "osmeaksdfiohuiHDFIUSDHFUkjadfhjk324",
|
||||
transgression: {
|
||||
sin_type: "Some Sin",
|
||||
description: "Some Description"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And return the created transgression as an object.
|
||||
|
||||
POST /transgressions/:id/confessions will take a JSON object as such:
|
||||
|
||||
```json
|
||||
{
|
||||
authenticity_token: "adsf123i478KJkhajksldfhjk0",
|
||||
confession: {
|
||||
description: "I did a thing",
|
||||
occurred_at: "2015-03-27"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Binary file not shown.
@ -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://coffeescript.org/
|
||||
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the confessions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
@ -0,0 +1,2 @@
|
||||
class ConfessionsController < ApplicationController
|
||||
end
|
||||
@ -0,0 +1,2 @@
|
||||
module ConfessionsHelper
|
||||
end
|
||||
@ -0,0 +1,8 @@
|
||||
class Confession < ActiveRecord::Base
|
||||
validates :description, presence: true
|
||||
validates :transgression, presence: true
|
||||
validates :occurred_at, presence: true
|
||||
|
||||
belongs_to :transgression
|
||||
delegate :sinner, to: :transgression
|
||||
end
|
||||
@ -1,3 +1,22 @@
|
||||
<% @transgressions.each do |trans| %>
|
||||
<h5>For the sin of <%= trans.sin_type %>: <%= trans.description %></h5>
|
||||
|
||||
<% @transgressions.each do |sin_type, trans| %>
|
||||
<h4>
|
||||
For the sin of <em><%= sin_type %></em>, your weaknesses are:
|
||||
</h4>
|
||||
<ul>
|
||||
<% trans.each do |t| %>
|
||||
<li>
|
||||
<%= t.description %>, with <%= t.confessions.count %> confessions:
|
||||
<% if t.confessions.count > 0 %>
|
||||
<ul>
|
||||
<% t.confessions.each do |c| %>
|
||||
<li>
|
||||
"<%= c.description %>" - <%= c.occurred_at %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
class CreateConfessions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :confessions do |t|
|
||||
t.references :transgression, index: true, foreign_key: true
|
||||
t.date :occured_at
|
||||
t.string :description
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,5 @@
|
||||
class ChangeColumnInConfessions < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :confessions, :occured_at, :occurred_at
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,6 @@
|
||||
class ChangeColumnsInConfessions < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :confessions, :description, :string, null: false
|
||||
change_column :confessions, :occurred_at, :datetime, null: false, default: Time.now
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ConfessionsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
transgression:
|
||||
occurred_at: 2015-10-30
|
||||
description: MyString
|
||||
|
||||
two:
|
||||
transgression:
|
||||
occurred_at: 2015-10-30
|
||||
description: MyString
|
||||
@ -0,0 +1,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ConfessionTest < ActiveSupport::TestCase
|
||||
test "the truth" do
|
||||
a = Confession.new
|
||||
|
||||
assert_not a.save
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue