Sha256: de4008044bb389f3c996a5c1215fde2178e6db3de150c276fdc0f0fb99dc18f7
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
class DictionariesController < ApplicationController before_action :set_dictionary, only: [:show, :edit, :update, :destroy] def index @dictionaries = Dictionary.where(resource_type: params[:resource_type], resource_id: params[:resource_id]).page(params[:page]).per(50) end def show end def new @dictionary = Dictionary.new(resource_type: params[:resource_type], resource_id: params[:resource_id]) end def edit end def create @dictionary = Dictionary.new(dictionary_params) respond_to do |format| if @dictionary.save format.html { redirect_to dictionaries_url(resource_type: @dictionary.resource_type, resource_id: @dictionary.resource_id), notice: '添加成功' } else format.html { render :new } end end end def update respond_to do |format| if @dictionary.update(dictionary_params) format.html { redirect_to dictionaries_url(resource_type: @dictionary.resource_type, resource_id: @dictionary.resource_id), notice: '修改成功' } else format.html { render :edit } end end end def destroy url = dictionaries_url(resource_type: @dictionary.resource_type, resource_id: @dictionary.resource_id) @dictionary.destroy respond_to do |format| format.html { redirect_to url, notice: '删除成功' } end end private def set_dictionary @dictionary = Dictionary.find(params[:id]) end def dictionary_params params.require(:dictionary).permit(:resource_type, :resource_id, :key, :value) end end
Version data entries
3 entries across 3 versions & 1 rubygems