You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
edu/app/controllers/user_actions_controller.rb

71 lines
2.1 KiB

class UserActionsController < ApplicationController
before_action :set_user_action, only: %i[ show edit update destroy ]
# GET /user_actions or /user_actions.json
def index
@user_actions = UserAction.all
end
# GET /user_actions/1 or /user_actions/1.json
def show
end
# GET /user_actions/new
def new
@user_action = UserAction.new
end
# GET /user_actions/1/edit
def edit
end
# POST /user_actions or /user_actions.json
def create
@user_action = UserAction.new(user_action_params)
respond_to do |format|
if @user_action.save
format.html { redirect_to user_action_url(@user_action), notice: "User action was successfully created." }
format.json { render :show, status: :created, location: @user_action }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @user_action.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /user_actions/1 or /user_actions/1.json
def update
respond_to do |format|
if @user_action.update(user_action_params)
format.html { redirect_to user_action_url(@user_action), notice: "User action was successfully updated." }
format.json { render :show, status: :ok, location: @user_action }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @user_action.errors, status: :unprocessable_entity }
end
end
end
# DELETE /user_actions/1 or /user_actions/1.json
def destroy
@user_action.destroy
respond_to do |format|
format.html { redirect_to user_actions_url, notice: "User action was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_user_action
@user_action = UserAction.find(params[:id])
end
# Only allow a list of trusted parameters through.
def user_action_params
params.require(:user_action).permit(:user_id, :action_type, :action_id, :ip)
end
end