Sha256: 5f5dd8b6f0a1564800a875ef15f0ef391eced4ed34876626c6c5b6dc30eec97b

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

class OfficersController < ApplicationController
  
  # Required params:
  #   - group_id or page_id
  #   - name
  #
  def create_officers_group
    @structureable = secure_structureable
    authorize! :create_officers_group_for, @structureable
    
    @officers_group = @structureable.officers_parent.child_groups.create name: params[:name]
    
    respond_to do |format|
      format.html { redirect_to @structureable }
      format.json { render json: @officers_group.attributes.merge({
        officers_group_entry_html: render_to_string(partial: 'officers/officers_group_entry', formats: [:html], handlers: [:haml], layout: false, locals: {officer_group: @officers_group, structureable: @structureable})
      })}
    end
  end
  
  private
  
  def secure_structureable
    return Group.find(params[:group_id]) if params[:group_id].present?
    return Page.find(params[:page_id]) if params[:page_id].present?
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
your_platform-1.0.1 app/controllers/officers_controller.rb
your_platform-1.0.0 app/controllers/officers_controller.rb
your_platform-0.0.2 app/controllers/officers_controller.rb