Class: Pulitzer::TagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pulitzer/tags_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
# File 'app/controllers/pulitzer/tags_controller.rb', line 27

def create
  @tag = Tag.new(tag_params)
  if @tag.save
    render partial: 'show_wrapper', locals: { tag: @tag }
  else
    render partial: new_template(@tag), locals: { tag: @tag }, status: 409
  end
end

#destroyObject



44
45
46
47
# File 'app/controllers/pulitzer/tags_controller.rb', line 44

def destroy
  @tag.destroy
  render nothing: true
end

#editObject



18
19
20
# File 'app/controllers/pulitzer/tags_controller.rb', line 18

def edit
  render partial: 'form', locals: { tag: @tag }
end

#indexObject



7
8
9
10
11
# File 'app/controllers/pulitzer/tags_controller.rb', line 7

def index
  @root_tags = Tag.root
  @flat_tags = Tag.flat
  render partial: 'index'
end

#newObject



13
14
15
16
# File 'app/controllers/pulitzer/tags_controller.rb', line 13

def new
  @tag = Tag.new(tag_params)
  render partial: new_template(@tag)
end

#showObject



22
23
24
25
# File 'app/controllers/pulitzer/tags_controller.rb', line 22

def show
  @tag = Tag.find(params[:id])
  render partial: 'show', locals: { tag: @tag }
end

#updateObject



36
37
38
39
40
41
42
# File 'app/controllers/pulitzer/tags_controller.rb', line 36

def update
  if @tag.update_attributes(tag_params)
    render partial: 'show', locals: { tag: @tag }
  else
    render partial: 'form', locals: { tag: @tag }, status: 409
  end
end