Class: Hicube::DocumentsController
Constant Summary
ApplicationController::FLASH_TYPES
Instance Method Summary
collapse
#after_sign_in_path_for, #notify, #notify_now
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/hicube/documents_controller.rb', line 22
def create
@document = Document.new document_params.except(:tags)
document_params[:tags].split(' ').each do |s|
@document.tags << Hicube::Tag.find_or_create_by(name: s)
end
@document.save!
respond_to do |format|
notify :notice, ::I18n.t('messages.resource.created',
type: Hicube::Document.model_name.human,
resource: @document
)
format.html { redirect_to action: :index }
end
end
|
#destroy ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/hicube/documents_controller.rb', line 39
def destroy
@document.destroy
respond_to do |format|
notify :warning, ::I18n.t('messages.resource.destroyed',
type: Hicube::Document.model_name.human,
resource: @document
)
format.html { redirect_to action: :index }
end
end
|
#edit ⇒ Object
51
52
|
# File 'app/controllers/hicube/documents_controller.rb', line 51
def edit
end
|
#index ⇒ Object
54
55
|
# File 'app/controllers/hicube/documents_controller.rb', line 54
def index
end
|
#show ⇒ Object
57
58
|
# File 'app/controllers/hicube/documents_controller.rb', line 57
def show
end
|
#update ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/hicube/documents_controller.rb', line 60
def update
@document.update_attributes document_params.except(:tags)
@document.tags = nil
params[:document][:tags].split(' ').each do |s|
@document.tags << Hicube::Tag.find_or_create_by(name: s)
end
@document.save!
respond_to do |format|
notify :notice, ::I18n.t('messages.resource.updated',
type: Hicube::Document.model_name.human,
resource: @document
)
format.html { redirect_to action: :index }
end
end
|