Class: HelenaAdministration::VersionsController
Instance Method Summary
collapse
#add_breadcrumb, #set_locale
Instance Method Details
#create ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 21
def create
@version = build_version
@version.update_attributes(version_params)
if @version.save
flash[:success] = t 'shared.actions.created'
else
flash.now[:danger] = t 'shared.actions.error'
end
respond_with @version, location: [@survey, @version]
end
|
#destroy ⇒ Object
51
52
53
54
55
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 51
def destroy
@version = @survey.versions.find params[:id]
flash[:success] = t 'shared.actions.deleted' if @version.destroy
redirect_to survey_path(@survey)
end
|
#edit ⇒ Object
32
33
34
35
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 32
def edit
@version.survey_detail ||= Helena::SurveyDetail.new
add_breadcrumb t 'helena_administration.versions.version', version: @version.version
end
|
#new ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 12
def new
source_version = @survey.newest_version
@version = @survey.versions.any? ? @survey.versions.build(source_version.attributes) : @survey.versions.build
@version.parent = source_version
@version.survey_detail = (@version.try(:survey_detail) || Helena::SurveyDetail.new)
@version.notes = ''
add_breadcrumb t('.new'), new_survey_version_path(@survey)
end
|
#show ⇒ Object
8
9
10
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 8
def show
add_breadcrumb t 'helena_administration.versions.version', version: @version.version
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/helena_administration/versions_controller.rb', line 37
def update
@version.update_attributes version_params
flash[:success] = t 'shared.actions.updated'
respond_with @version, location: [:edit, @survey, @version]
end
|