Class: DictionariesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/dictionaries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/dictionaries_controller.rb', line 18

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

#destroyObject



40
41
42
43
44
45
46
# File 'app/controllers/dictionaries_controller.rb', line 40

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

#editObject



15
16
# File 'app/controllers/dictionaries_controller.rb', line 15

def edit
end

#indexObject



4
5
6
# File 'app/controllers/dictionaries_controller.rb', line 4

def index
  @dictionaries = Dictionary.where(resource_type: params[:resource_type], resource_id: params[:resource_id])
end

#newObject



11
12
13
# File 'app/controllers/dictionaries_controller.rb', line 11

def new
  @dictionary = Dictionary.new(resource_type: params[:resource_type], resource_id: params[:resource_id])
end

#showObject



8
9
# File 'app/controllers/dictionaries_controller.rb', line 8

def show
end

#updateObject



30
31
32
33
34
35
36
37
38
# File 'app/controllers/dictionaries_controller.rb', line 30

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