-
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.
rails g scaffold lib_ptg_folder name:string:uniq flavor:string month:…
…integer update:date
- Loading branch information
1 parent
ae8f472
commit 2c50729
Showing
15 changed files
with
222 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,74 @@ | ||
class LibPtgFoldersController < ApplicationController | ||
before_action :set_lib_ptg_folder, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /lib_ptg_folders | ||
# GET /lib_ptg_folders.json | ||
def index | ||
@lib_ptg_folders = LibPtgFolder.all | ||
end | ||
|
||
# GET /lib_ptg_folders/1 | ||
# GET /lib_ptg_folders/1.json | ||
def show | ||
end | ||
|
||
# GET /lib_ptg_folders/new | ||
def new | ||
@lib_ptg_folder = LibPtgFolder.new | ||
end | ||
|
||
# GET /lib_ptg_folders/1/edit | ||
def edit | ||
end | ||
|
||
# POST /lib_ptg_folders | ||
# POST /lib_ptg_folders.json | ||
def create | ||
@lib_ptg_folder = LibPtgFolder.new(lib_ptg_folder_params) | ||
|
||
respond_to do |format| | ||
if @lib_ptg_folder.save | ||
format.html { redirect_to @lib_ptg_folder, notice: 'Lib ptg folder was successfully created.' } | ||
format.json { render :show, status: :created, location: @lib_ptg_folder } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @lib_ptg_folder.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /lib_ptg_folders/1 | ||
# PATCH/PUT /lib_ptg_folders/1.json | ||
def update | ||
respond_to do |format| | ||
if @lib_ptg_folder.update(lib_ptg_folder_params) | ||
format.html { redirect_to @lib_ptg_folder, notice: 'Lib ptg folder was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @lib_ptg_folder } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @lib_ptg_folder.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /lib_ptg_folders/1 | ||
# DELETE /lib_ptg_folders/1.json | ||
def destroy | ||
@lib_ptg_folder.destroy | ||
respond_to do |format| | ||
format.html { redirect_to lib_ptg_folders_url, notice: 'Lib ptg folder was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_lib_ptg_folder | ||
@lib_ptg_folder = LibPtgFolder.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def lib_ptg_folder_params | ||
params.require(:lib_ptg_folder).permit(:name, :flavor, :month, :update) | ||
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 @@ | ||
class LibPtgFolder < 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,37 @@ | ||
<%= form_with(model: lib_ptg_folder, local: true) do |form| %> | ||
<% if lib_ptg_folder.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(lib_ptg_folder.errors.count, "error") %> prohibited this lib_ptg_folder from being saved:</h2> | ||
|
||
<ul> | ||
<% lib_ptg_folder.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :name %> | ||
<%= form.text_field :name %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :flavor %> | ||
<%= form.text_field :flavor %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :month %> | ||
<%= form.number_field :month %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :update %> | ||
<%= form.date_select :update %> | ||
</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! lib_ptg_folder, :id, :name, :flavor, :month, :update, :created_at, :updated_at | ||
json.url lib_ptg_folder_url(lib_ptg_folder, 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 Lib Ptg Folder</h1> | ||
|
||
<%= render 'form', lib_ptg_folder: @lib_ptg_folder %> | ||
<%= link_to 'Show', @lib_ptg_folder %> | | ||
<%= link_to 'Back', lib_ptg_folders_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,33 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Lib Ptg Folders</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Flavor</th> | ||
<th>Month</th> | ||
<th>Update</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @lib_ptg_folders.each do |lib_ptg_folder| %> | ||
<tr> | ||
<td><%= lib_ptg_folder.name %></td> | ||
<td><%= lib_ptg_folder.flavor %></td> | ||
<td><%= lib_ptg_folder.month %></td> | ||
<td><%= lib_ptg_folder.update %></td> | ||
<td><%= link_to 'Show', lib_ptg_folder %></td> | ||
<td><%= link_to 'Edit', edit_lib_ptg_folder_path(lib_ptg_folder) %></td> | ||
<td><%= link_to 'Destroy', lib_ptg_folder, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Lib Ptg Folder', new_lib_ptg_folder_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! @lib_ptg_folders, partial: "lib_ptg_folders/lib_ptg_folder", as: :lib_ptg_folder |
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 Lib Ptg Folder</h1> | ||
|
||
<%= render 'form', lib_ptg_folder: @lib_ptg_folder %> | ||
<%= link_to 'Back', lib_ptg_folders_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,24 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Name:</strong> | ||
<%= @lib_ptg_folder.name %> | ||
</p> | ||
|
||
<p> | ||
<strong>Flavor:</strong> | ||
<%= @lib_ptg_folder.flavor %> | ||
</p> | ||
|
||
<p> | ||
<strong>Month:</strong> | ||
<%= @lib_ptg_folder.month %> | ||
</p> | ||
|
||
<p> | ||
<strong>Update:</strong> | ||
<%= @lib_ptg_folder.update %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_lib_ptg_folder_path(@lib_ptg_folder) %> | | ||
<%= link_to 'Back', lib_ptg_folders_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! "lib_ptg_folders/lib_ptg_folder", lib_ptg_folder: @lib_ptg_folder |
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,13 @@ | ||
class CreateLibPtgFolders < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :lib_ptg_folders do |t| | ||
t.string :name | ||
t.string :flavor | ||
t.integer :month | ||
t.date :update | ||
|
||
t.timestamps | ||
end | ||
add_index :lib_ptg_folders, :name, unique: true | ||
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,8 @@ | ||
FactoryBot.define do | ||
factory :lib_ptg_folder do | ||
name { "MyString" } | ||
flavor { "MyString" } | ||
month { 1 } | ||
update { "2019-06-10" } | ||
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,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe LibPtgFolder, type: :model 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,10 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "LibPtgFolders", type: :request do | ||
describe "GET /lib_ptg_folders" do | ||
it "works! (now write some real specs)" do | ||
get lib_ptg_folders_path | ||
expect(response).to have_http_status(200) | ||
end | ||
end | ||
end |