Class: Admin::Posts::TagsController

Inherits:
ApplicationController show all
Defined in:
lib/ecrire/app/controllers/admin/posts/tags_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#posts

Methods inherited from ApplicationController

#current_user, #signed_in?, #url

Instance Method Details

#indexObject



5
6
7
8
# File 'lib/ecrire/app/controllers/admin/posts/tags_controller.rb', line 5

def index
  @post = Admin::Post.find(params[:post_id])
  @tags = Admin::Tag.all
end

#toggleObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ecrire/app/controllers/admin/posts/tags_controller.rb', line 10

def toggle
  @post = Admin::Post.find(params[:post_id])
  @tag = Admin::Tag.find(params[:tag_id])
  if @post.tags.include? @tag
    @post.tags = @post.tags.where.not(id: @tag.id)
  else
    @post.tags << @tag
  end

  @post.save!
end