-
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.
Merge branch 'feature/encode-controller' into develop
* feature/encode-controller: rails g scaffold encode log:text started_at:timestamp ended_at:timestamp runtime:float completed:boolean user:references published:boolean # Conflicts: # config/routes.rb
- Loading branch information
Showing
15 changed files
with
308 additions
and
0 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,3 @@ | ||
// Place all the styles related to the encodes controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://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,65 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
margin: 33px; } | ||
|
||
body, 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; } | ||
|
||
a:visited { | ||
color: #666; } | ||
|
||
a:hover { | ||
color: #fff; | ||
background-color: #000; } | ||
|
||
th { | ||
padding-bottom: 5px; } | ||
|
||
td { | ||
padding: 0 5px 7px; } | ||
|
||
div.field, | ||
div.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 7px 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; } | ||
|
||
#error_explanation h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px -7px 0; | ||
background-color: #c00; | ||
color: #fff; } | ||
|
||
#error_explanation ul li { | ||
font-size: 12px; | ||
list-style: square; } | ||
|
||
label { | ||
display: block; } |
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,74 @@ | ||
class EncodesController < ApplicationController | ||
before_action :set_encode, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /encodes | ||
# GET /encodes.json | ||
def index | ||
@encodes = Encode.all | ||
end | ||
|
||
# GET /encodes/1 | ||
# GET /encodes/1.json | ||
def show | ||
end | ||
|
||
# GET /encodes/new | ||
def new | ||
@encode = Encode.new | ||
end | ||
|
||
# GET /encodes/1/edit | ||
def edit | ||
end | ||
|
||
# POST /encodes | ||
# POST /encodes.json | ||
def create | ||
@encode = Encode.new(encode_params) | ||
|
||
respond_to do |format| | ||
if @encode.save | ||
format.html { redirect_to @encode, notice: 'Encode was successfully created.' } | ||
format.json { render :show, status: :created, location: @encode } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @encode.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /encodes/1 | ||
# PATCH/PUT /encodes/1.json | ||
def update | ||
respond_to do |format| | ||
if @encode.update(encode_params) | ||
format.html { redirect_to @encode, notice: 'Encode was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @encode } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @encode.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /encodes/1 | ||
# DELETE /encodes/1.json | ||
def destroy | ||
@encode.destroy | ||
respond_to do |format| | ||
format.html { redirect_to encodes_url, notice: 'Encode was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_encode | ||
@encode = Encode.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def encode_params | ||
params.require(:encode).permit(:log, :started_at, :ended_at, :runtime, :completed, :user_id, :published) | ||
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 EncodesHelper | ||
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,3 @@ | ||
class Encode < ApplicationRecord | ||
belongs_to :user | ||
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 @@ | ||
json.extract! encode, :id, :log, :started_at, :ended_at, :runtime, :completed, :user_id, :published, :created_at, :updated_at | ||
json.url encode_url(encode, format: :json) |
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,52 @@ | ||
<%= form_with(model: encode, local: true) do |form| %> | ||
<% if encode.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(encode.errors.count, "error") %> prohibited this encode from being saved:</h2> | ||
|
||
<ul> | ||
<% encode.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :log %> | ||
<%= form.text_area :log %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :started_at %> | ||
<%= form.datetime_select :started_at %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :ended_at %> | ||
<%= form.datetime_select :ended_at %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :runtime %> | ||
<%= form.text_field :runtime %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :completed %> | ||
<%= form.check_box :completed %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :user_id %> | ||
<%= form.text_field :user_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :published %> | ||
<%= form.check_box :published %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.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 Encode</h1> | ||
|
||
<%= render 'form', encode: @encode %> | ||
|
||
<%= link_to 'Show', @encode %> | | ||
<%= link_to 'Back', encodes_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 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Encodes</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Log</th> | ||
<th>Started at</th> | ||
<th>Ended at</th> | ||
<th>Runtime</th> | ||
<th>Completed</th> | ||
<th>User</th> | ||
<th>Published</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @encodes.each do |encode| %> | ||
<tr> | ||
<td><%= encode.log %></td> | ||
<td><%= encode.started_at %></td> | ||
<td><%= encode.ended_at %></td> | ||
<td><%= encode.runtime %></td> | ||
<td><%= encode.completed %></td> | ||
<td><%= encode.user_id %></td> | ||
<td><%= encode.published %></td> | ||
<td><%= link_to 'Show', encode %></td> | ||
<td><%= link_to 'Edit', edit_encode_path(encode) %></td> | ||
<td><%= link_to 'Destroy', encode, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Encode', new_encode_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 @@ | ||
json.array! @encodes, partial: "encodes/encode", as: :encode |
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 Encode</h1> | ||
|
||
<%= render 'form', encode: @encode %> | ||
|
||
<%= link_to 'Back', encodes_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 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Log:</strong> | ||
<%= @encode.log %> | ||
</p> | ||
|
||
<p> | ||
<strong>Started at:</strong> | ||
<%= @encode.started_at %> | ||
</p> | ||
|
||
<p> | ||
<strong>Ended at:</strong> | ||
<%= @encode.ended_at %> | ||
</p> | ||
|
||
<p> | ||
<strong>Runtime:</strong> | ||
<%= @encode.runtime %> | ||
</p> | ||
|
||
<p> | ||
<strong>Completed:</strong> | ||
<%= @encode.completed %> | ||
</p> | ||
|
||
<p> | ||
<strong>User:</strong> | ||
<%= @encode.user_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Published:</strong> | ||
<%= @encode.published %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_encode_path(@encode) %> | | ||
<%= link_to 'Back', encodes_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 @@ | ||
json.partial! "encodes/encode", encode: @encode |
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,5 @@ | ||
Rails.application.routes.draw do | ||
devise_for :users | ||
resources :encodes | ||
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html | ||
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,15 @@ | ||
class CreateEncodes < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :encodes do |t| | ||
t.text :log | ||
t.timestamp :started_at | ||
t.timestamp :ended_at | ||
t.float :runtime | ||
t.boolean :completed | ||
t.references :user, null: false, foreign_key: true | ||
t.boolean :published | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |