commissioner scaffold

This commit is contained in:
Zin Lin Phyo
2017-08-21 13:30:04 +06:30
parent 06619d30dc
commit 7b0db433c4
26 changed files with 586 additions and 50 deletions

View File

@@ -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/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the Commissioners controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,74 @@
class CommissionersController < ApplicationController
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
# GET /commissioners
# GET /commissioners.json
def index
@commissioners = Commissioner.all
end
# GET /commissioners/1
# GET /commissioners/1.json
def show
end
# GET /commissioners/new
def new
@commissioner = Commissioner.new
end
# GET /commissioners/1/edit
def edit
end
# POST /commissioners
# POST /commissioners.json
def create
@commissioner = Commissioner.new(commissioner_params)
respond_to do |format|
if @commissioner.save
format.html { redirect_to @commissioner, notice: 'Commissioner was successfully created.' }
format.json { render :show, status: :created, location: @commissioner }
else
format.html { render :new }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /commissioners/1
# PATCH/PUT /commissioners/1.json
def update
respond_to do |format|
if @commissioner.update(commissioner_params)
format.html { redirect_to @commissioner, notice: 'Commissioner was successfully updated.' }
format.json { render :show, status: :ok, location: @commissioner }
else
format.html { render :edit }
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
end
end
end
# DELETE /commissioners/1
# DELETE /commissioners/1.json
def destroy
@commissioner.destroy
respond_to do |format|
format.html { redirect_to commissioners_url, notice: 'Commissioner was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commissioner
@commissioner = Commissioner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commissioner_params
params.fetch(:commissioner, {})
end
end

View File

@@ -0,0 +1,2 @@
module CommissionersHelper
end

View File

@@ -0,0 +1,2 @@
class Commissioner < ApplicationRecord
end

View File

@@ -0,0 +1,2 @@
json.extract! commissioner, :id, :created_at, :updated_at
json.url commissioner_url(commissioner, format: :json)

View File

@@ -0,0 +1,10 @@
<%= simple_form_for(@commissioner) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,6 @@
<h1>Editing Commissioner</h1>
<%= render 'form', commissioner: @commissioner %>
<%= link_to 'Show', @commissioner %> |
<%= link_to 'Back', commissioners_path %>

View File

@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>
<h1>Commissioners</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @commissioners.each do |commissioner| %>
<tr>
<td><%= link_to 'Show', commissioner %></td>
<td><%= link_to 'Edit', edit_commissioner_path(commissioner) %></td>
<td><%= link_to 'Destroy', commissioner, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Commissioner', new_commissioner_path %>

View File

@@ -0,0 +1 @@
json.array! @commissioners, partial: 'commissioners/commissioner', as: :commissioner

View File

@@ -0,0 +1,5 @@
<h1>New Commissioner</h1>
<%= render 'form', commissioner: @commissioner %>
<%= link_to 'Back', commissioners_path %>

View File

@@ -0,0 +1,4 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Edit', edit_commissioner_path(@commissioner) %> |
<%= link_to 'Back', commissioners_path %>

View File

@@ -0,0 +1 @@
json.partial! "commissioners/commissioner", commissioner: @commissioner