Class: Railspress::Admin::ContentGroupsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Railspress::Admin::ContentGroupsController
- Defined in:
- app/controllers/railspress/admin/content_groups_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 24 def create @content_group = ContentGroup.new(content_group_params) @content_group. = &.id if if @content_group.save redirect_to admin_content_group_path(@content_group), notice: "Content group '#{@content_group.name}' created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 46 def destroy if @content_group.soft_delete redirect_to admin_content_groups_path, notice: "Content group '#{@content_group.name}' deleted." else redirect_to admin_content_group_path(@content_group), alert: "Cannot delete '#{@content_group.name}' — it contains required content elements." end end |
#edit ⇒ Object
35 36 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 35 def edit end |
#index ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 8 def index @content_groups = ContentGroup.active .includes(:content_elements) .order(created_at: :desc) end |
#new ⇒ Object
20 21 22 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 20 def new @content_group = ContentGroup.new end |
#show ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 14 def show @content_elements = @content_group.content_elements .active .ordered end |
#update ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/railspress/admin/content_groups_controller.rb', line 38 def update if @content_group.update(content_group_params) redirect_to admin_content_group_path(@content_group), notice: "Content group '#{@content_group.name}' updated." else render :edit, status: :unprocessable_entity end end |