parent
002574f559
commit
5a74813ce4
Binary file not shown.
|
After Width: | Height: | Size: 247 KiB |
@ -0,0 +1,7 @@
|
||||
$(function () {
|
||||
$('img').hover(function () {
|
||||
$(this).addClass('dancing');
|
||||
}, function () {
|
||||
$(this).removeClass('dancing');
|
||||
});
|
||||
});
|
||||
@ -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,10 @@
|
||||
// Place all the styles related to the transgressions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
form input, form select {
|
||||
padding: 0.5rem;
|
||||
font-size: 2rem;
|
||||
border: 1px solid green;
|
||||
width: 75%;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
class TransgressionsController < ApplicationController
|
||||
before_action :require_current_user
|
||||
|
||||
def new
|
||||
@transgression = Transgression.new
|
||||
end
|
||||
|
||||
def create
|
||||
@transgression = current_user.transgressions
|
||||
.new(transgression_params)
|
||||
|
||||
if @transgression.save
|
||||
redirect_to transgressions_path
|
||||
else
|
||||
flash[:message] = @transgression.errors.full_messages.to_sentence
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
# params[:id]
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def index
|
||||
@transgressions = current_user.transgressions
|
||||
end
|
||||
|
||||
def delete
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def transgression_params
|
||||
return params.require(:transgression)
|
||||
.permit(:sin_type, :description)
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,2 @@
|
||||
module TransgressionsHelper
|
||||
end
|
||||
@ -0,0 +1,14 @@
|
||||
class Transgression < ActiveRecord::Base
|
||||
SIN_TYPES = [
|
||||
'Gluttony', 'Greed', 'Anger', 'Pride',
|
||||
'Lust', 'Sloth', 'Envy'
|
||||
]
|
||||
|
||||
validates :description, presence: true
|
||||
validates :user, presence: true
|
||||
validates :sin_type, inclusion: { in: SIN_TYPES }
|
||||
|
||||
belongs_to :user
|
||||
end
|
||||
|
||||
# Transgression::SIN_TYPES
|
||||
@ -0,0 +1,17 @@
|
||||
<header>
|
||||
<div class="logo">
|
||||
<%= image_tag 'logo.png' %>
|
||||
<span>
|
||||
The Sins We Commit
|
||||
</span>
|
||||
</div>
|
||||
<nav>
|
||||
<% if current_user %>
|
||||
<a href="<%= new_transgression_path %>">
|
||||
Please me, mortal!
|
||||
</a>
|
||||
<% end %>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<%= javascript_include_tag 'login_signup.js' %>
|
||||
@ -0,0 +1,3 @@
|
||||
<% @transgressions.each do |trans| %>
|
||||
<h5>For the sin of <%= trans.sin_type %>: <%= trans.description %></h5>
|
||||
<% end %>
|
||||
@ -0,0 +1,17 @@
|
||||
<form action="<%= transgressions_path %>" method="POST"
|
||||
class='transgression'>
|
||||
<input type="hidden" name="authenticity_token"
|
||||
value="<%= form_authenticity_token %>">
|
||||
<input type="text" name="transgression[description]"
|
||||
placeholder="Weaknesses are beautiful..."
|
||||
value="<%= @transgression.description %>"><br/>
|
||||
<select name="transgression[sin_type]">
|
||||
<% Transgression::SIN_TYPES.each do |sin| %>
|
||||
<option value="<%= sin %>"
|
||||
<%= @transgression.sin_type == sin ? "selected" : "" %>>
|
||||
<%= sin %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
<input type="submit" value="Here I am">
|
||||
</form>
|
||||
@ -0,0 +1,13 @@
|
||||
class CreateTransgressions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :transgressions do |t|
|
||||
t.references :user, index: true, foreign_key: true
|
||||
t.string :description, null: false
|
||||
t.string :sin_type, null: false
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_index :transgressions, :sin_type
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TransgressionsControllerTest < 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:
|
||||
user_id:
|
||||
description: MyString
|
||||
sin_type: MyString
|
||||
|
||||
two:
|
||||
user_id:
|
||||
description: MyString
|
||||
sin_type: MyString
|
||||
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TransgressionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in new issue