Class: Realiser::Web::SettingsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Realiser::Web::SettingsController
- Defined in:
- app/controllers/realiser/web/settings_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#destroy ⇒ Object
rubocop:enable Style/RedundantArgument.
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
rubocop:disable Style/RedundantArgument.
Instance Method Details
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 39 def create @setting = Realiser::Setting.new(form_params) if @setting.invalid? flash.now[:danger] = @setting.errors..join(', ') return render :new end @setting.save! flash[:success] = 'Succesfully created a new setting' redirect_to root_path end |
#destroy ⇒ Object
rubocop:enable Style/RedundantArgument
32 33 34 35 36 37 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 32 def destroy setting = Realiser::Setting.find_by(id: params[:id]) setting.destroy! flash[:success] = 'Successfully deleted the setting' redirect_to root_path end |
#edit ⇒ Object
16 17 18 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 16 def edit @setting = Realiser::Setting.find_by(id: params[:id]) end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 4 def index @settings = Realiser::Setting.all end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 8 def new @setting = Realiser::Setting.new end |
#show ⇒ Object
12 13 14 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 12 def show @setting = Realiser::Setting.find_by(id: params[:id]) end |
#update ⇒ Object
rubocop:disable Style/RedundantArgument
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/realiser/web/settings_controller.rb', line 21 def update setting = Realiser::Setting.find_by(id: params[:id]) if setting.update(form_params) flash[:success] = 'Successfully to update the setting' return redirect_to web_setting_path(setting) end flash.now[:danger] = setting.errors..join('') render :edit end |