Class: Admin::Posts::TagsController
Instance Method Summary
collapse
#posts
#current_user, #signed_in?, #url
Instance Method Details
#index ⇒ Object
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
|
#toggle ⇒ Object
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
|