-
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.
- Loading branch information
1 parent
ad36d32
commit 889b29c
Showing
24 changed files
with
518 additions
and
3 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,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,3 @@ | ||
// Place all the styles related to the TextSamples 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,74 @@ | ||
class TextSamplesController < ApplicationController | ||
before_action :set_text_sample, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /text_samples | ||
# GET /text_samples.json | ||
def index | ||
@text_samples = TextSample.all | ||
end | ||
|
||
# GET /text_samples/1 | ||
# GET /text_samples/1.json | ||
def show | ||
end | ||
|
||
# GET /text_samples/new | ||
def new | ||
@text_sample = TextSample.new | ||
end | ||
|
||
# GET /text_samples/1/edit | ||
def edit | ||
end | ||
|
||
# POST /text_samples | ||
# POST /text_samples.json | ||
def create | ||
@text_sample = TextSample.new(text_sample_params) | ||
|
||
respond_to do |format| | ||
if @text_sample.save | ||
format.html { redirect_to @text_sample, notice: 'Text sample was successfully created.' } | ||
format.json { render :show, status: :created, location: @text_sample } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @text_sample.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /text_samples/1 | ||
# PATCH/PUT /text_samples/1.json | ||
def update | ||
respond_to do |format| | ||
if @text_sample.update(text_sample_params) | ||
format.html { redirect_to @text_sample, notice: 'Text sample was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @text_sample } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @text_sample.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /text_samples/1 | ||
# DELETE /text_samples/1.json | ||
def destroy | ||
@text_sample.destroy | ||
respond_to do |format| | ||
format.html { redirect_to text_samples_url, notice: 'Text sample was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_text_sample | ||
@text_sample = TextSample.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def text_sample_params | ||
params.require(:text_sample).permit(:description, :text) | ||
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 TextSamplesHelper | ||
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 @@ | ||
class TextSample < ApplicationRecord | ||
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,27 @@ | ||
<%= form_with(model: text_sample, local: true) do |form| %> | ||
<% if text_sample.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(text_sample.errors.count, "error") %> prohibited this text_sample from being saved:</h2> | ||
|
||
<ul> | ||
<% text_sample.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :description %> | ||
<%= form.text_field :description %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :text %> | ||
<%= form.text_area :text %> | ||
</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,2 @@ | ||
json.extract! text_sample, :id, :description, :text, :created_at, :updated_at | ||
json.url text_sample_url(text_sample, 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,6 @@ | ||
<h1>Editing Text Sample</h1> | ||
|
||
<%= render 'form', text_sample: @text_sample %> | ||
|
||
<%= link_to 'Show', @text_sample %> | | ||
<%= link_to 'Back', text_samples_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,29 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Text Samples</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Description</th> | ||
<th>Text</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @text_samples.each do |text_sample| %> | ||
<tr> | ||
<td><%= text_sample.description %></td> | ||
<td><%= text_sample.text %></td> | ||
<td><%= link_to 'Show', text_sample %></td> | ||
<td><%= link_to 'Edit', edit_text_sample_path(text_sample) %></td> | ||
<td><%= link_to 'Destroy', text_sample, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Text Sample', new_text_sample_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! @text_samples, partial: "text_samples/text_sample", as: :text_sample |
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 Text Sample</h1> | ||
|
||
<%= render 'form', text_sample: @text_sample %> | ||
|
||
<%= link_to 'Back', text_samples_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,14 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Description:</strong> | ||
<%= @text_sample.description %> | ||
</p> | ||
|
||
<p> | ||
<strong>Text:</strong> | ||
<%= @text_sample.text %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_text_sample_path(@text_sample) %> | | ||
<%= link_to 'Back', text_samples_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! "text_samples/text_sample", text_sample: @text_sample |
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,6 +1,6 @@ | ||
Rails.application.routes.draw do | ||
get 'welcome/index' | ||
resources :text_samples | ||
|
||
root 'welcome#index' | ||
root 'text_samples#index' | ||
# 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,10 @@ | ||
class CreateTextSamples < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :text_samples do |t| | ||
t.string :description | ||
t.text :text | ||
|
||
t.timestamps | ||
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
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 @@ | ||
require 'rails_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the TextSamplesHelper. For example: | ||
# | ||
# describe TextSamplesHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# expect(helper.concat_strings("this","that")).to eq("this that") | ||
# end | ||
# end | ||
# end | ||
RSpec.describe TextSamplesHelper, type: :helper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe TextSample, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
Oops, something went wrong.