Skip to content

Commit

Permalink
refs #5 一旦現状の手持ちをpush
Browse files Browse the repository at this point in the history
  • Loading branch information
hamapu committed Oct 2, 2019
1 parent 3f8d41c commit 321a6f3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 174 deletions.
43 changes: 18 additions & 25 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
render_ok(User.all)
end

# GET /users/1
Expand All @@ -14,7 +14,6 @@ def show

# GET /users/new
def new
@user = User.new
end

# GET /users/1/edit
Expand All @@ -24,47 +23,41 @@ def edit
# POST /users
# POST /users.json
def create
@user = User.new(user_params)
user = User.new(user_params)

respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
if user.save
render_ok(user)
else
render_ng(400, user.errors)
end
end

# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
if User.where( id: user_params[:id] ).update( name: user_params[:name], mail_address: user_params[:mail_address] )
render_ok(user_params)
else
render_ng(400, user.errors)
end
end

# DELETE /users/1
# DELETE /users/1.json
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
#
end

private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
user = User.find(params[:id])

if user.save
render_ok(user)
else
render_ng(400, user.errors)
end
end

# Never trust parameters from the scary internet, only allow the white list through.
Expand Down
14 changes: 11 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_09_18_012131) do
ActiveRecord::Schema.define(version: 2019_10_01_181100) do

create_table "issues", force: :cascade do |t|
t.string "title"
t.string "title", null: false
t.text "body"
t.integer "kind"
t.integer "kind", default: 3
t.integer "del_flg", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "users", force: :cascade do |t|
t.string "name", null: false
t.string "mail_address"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Expand Down
141 changes: 0 additions & 141 deletions spec/controllers/users_controller_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/models/user_spec.rb

This file was deleted.

0 comments on commit 321a6f3

Please sign in to comment.