Class: Wco::TagsController
Instance Method Summary
collapse
#home, #tinymce
#my_truthy?, #obfuscate, #pp_amount, #pp_currency, #pp_date, #pp_datetime, #pp_money, #pp_percent, #pp_time, #pretty_date
Instance Method Details
#add_to ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/wco/tags_controller.rb', line 42
def add_to
@tag = Wco::Tag.find params[:id]
resource = params[:resource].constantize.find params[:resource_id]
authorize! :update, @tag
resource.tags.push @tag
flag = resource.save
flash_notice 'maybe?'
redirect_to request.referrer
end
|
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'app/controllers/wco/tags_controller.rb', line 6
def create
@tag = Wco::Tag.new params[:tag].permit!
authorize! :create, @tag
if @tag.save
flash_notice "created tag"
else
flash_alert "Cannot create tag: #{@tag.errors.messages}"
end
redirect_to action: 'index'
end
|
#destroy ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/wco/tags_controller.rb', line 17
def destroy
@tag = Wco::Tag.find params[:id]
authorize! :destroy, @tag
if @tag.destroy
flash_notice 'ok'
else
flash_alert 'No luck.'
end
redirect_to action: 'index'
end
|
#edit ⇒ Object
28
29
30
31
|
# File 'app/controllers/wco/tags_controller.rb', line 28
def edit
@tag = Wco::Tag.find params[:id]
authorize! :edit, @tag
end
|
#index ⇒ Object
33
34
35
36
|
# File 'app/controllers/wco/tags_controller.rb', line 33
def index
authorize! :index, Wco::Tag
@tags = Wco::Tag.all
end
|
#new ⇒ Object
38
39
40
|
# File 'app/controllers/wco/tags_controller.rb', line 38
def new
authorize! :new, Wco::Tag
end
|
#remove_from ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/wco/tags_controller.rb', line 53
def remove_from
@tag = Wco::Tag.find params[:id]
resource = params[:resource].constantize.find params[:resource_id]
authorize! :update, @tag
resource.tags.delete @tag
flag = resource.save
flash_notice 'maybe?'
redirect_to request.referrer
end
|
#show ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/controllers/wco/tags_controller.rb', line 64
def show
@tag = Wco::Tag.find params[:id]
authorize! :show, @tag
@galleries = @tag.galleries(
).page( params[:galleries_page] ).per( current_profile.per_page )
@reports = @tag.reports(
).page( params[:reports_page] ).per( current_profile.per_page )
end
|
#update ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'app/controllers/wco/tags_controller.rb', line 76
def update
@tag = Wco::Tag.find params[:id]
authorize! :update, @tag
if @tag.update params[:tag].permit!
flash_notice "updated tag"
else
flash_alert "Cannot update tag: #{@tag.errors.messages}"
end
redirect_to action: 'index'
end
|