personal-journal/app/controllers/admin/journal_levels_controller.rb

51 lines
1017 B
Ruby

class Admin::JournalLevelsController < ApplicationController
before_action :set_journal_level, only: [:edit, :update, :destroy]
def initialize
super
@app_type = 'journal_level'
end
def new
@journal_level = JournalLevel.new
end
def create
@journal_level = JournalLevel.new(journal_level_attributes)
respond_to do |format|
if @journal_level.save
format.js { render 'create_writing_journal_setting' }
end
end
end
def edit
end
def update
respond_to do |format|
if @journal_level.update_attributes(journal_level_attributes)
format.js { render 'update_writing_journal_setting' }
end
end
end
def destroy
@journal_level.destroy
respond_to do |format|
format.js { render 'delete_journal_setting' }
end
end
private
def set_journal_level
@journal_level = JournalLevel.find(params[:id])
end
def journal_level_attributes
params.require(:journal_level).permit! rescue nil
end
end