Sha256: f5a1b6ee51188a952b895da4068891f67f37eefc9b50f91826a1341ed4b7b459
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
class DictionariesController < ApplicationController before_action :set_dictionary, only: [:show, :edit, :update, :destroy] layout 'report' def index @dictionaries = Dictionary.where(resource_type: params[:resource_type], resource_id: params[:resource_id]) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
treport-0.2.0 | app/controllers/dictionaries_controller.rb |
treport-0.1.0 | app/controllers/dictionaries_controller.rb |