Class: Infold::AppsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Infold::AppsController
- Defined in:
- app/controllers/infold/apps_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/infold/apps_controller.rb', line 11 def create project = Project.first @app = App.new @app.assign_attributes(post_params) @app.build_app_view_index @app.build_app_view_show @app.app_views.compact.each(&:reject_unchecked) if @app.save project..create!(app: @app, seq: project..size + 1, kind: :app) redirect_to edit_app_path(@app), flash: { info: t('infold.flash.created') } else Rails.logger.debug "エラー #{@app.errors.}" flash.now[:warning] = t('infold.flash.invalid') render status: :unprocessable_entity end end |
#destroy ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/infold/apps_controller.rb', line 46 def destroy @app = App.find(params[:id]) @app.destroy! redirect_to new_app_path, status: :see_other, flash: { info: t('infold.flash.destroyed') } end |
#edit ⇒ Object
28 29 30 31 |
# File 'app/controllers/infold/apps_controller.rb', line 28 def edit @app = App.find(params[:id]) @app.build_views end |
#index ⇒ Object
3 4 |
# File 'app/controllers/infold/apps_controller.rb', line 3 def index end |
#new ⇒ Object
6 7 8 9 |
# File 'app/controllers/infold/apps_controller.rb', line 6 def new @app = App.new @app.build_views end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/infold/apps_controller.rb', line 33 def update @app = App.find(params[:id]) @app.assign_attributes(post_params) @app.app_views.compact.each(&:reject_unchecked) if @app.save redirect_to edit_app_path(@app), flash: { info: t('infold.flash.updated') } else Rails.logger.debug "エラー #{@app.errors.}" flash.now[:warning] = t('infold.flash.invalid') render status: :unprocessable_entity end end |