Sha256: c12573c39a17698ec281d6336062e820b237b2bf22016b179b942a56ea767dc3

Contents?: true

Size: 1.46 KB

Versions: 41

Compression:

Stored size: 1.46 KB

Contents

class Pulitzer::PartialsController < Pulitzer::ApplicationController
  before_filter :set_partial, except: [:new, :create, :update_all]

  def new
    @partial = Pulitzer::Partial.new(partial_params)
    @free_form_section = @partial.free_form_section
    render partial: 'new', locals: { partial: @partial }
  end

  def create
    @free_form_section = Pulitzer::FreeFormSection.find partial_params[:free_form_section_id]
    @partial = @free_form_section.partials.create partial_params
    if @partial && @partial.errors.empty?
      Pulitzer::CreatePartialContentElements.new(@partial).call 
      render partial: 'show_wrapper', locals: { partial: @partial }
    else
      render partial: 'new', locals: {partial: @partial}
    end
  end

  def show
    render partial: 'show', locals: { partial: @partial }
  end

  def edit
    render partial: 'form', locals: { partial: @partial }
  end

  def update
    @partial.update partial_params
    render partial: 'show', locals: { partial: @partial }
  end

  def update_all
    partials = Pulitzer::Partial.find params[:partial]
    partials.each do |partial|
      new_sort_order = params[:partial].index(partial.id.to_s)
      partial.update_attribute(:sort_order, new_sort_order)
    end
    render nothing: true
  end

  def destroy
    @partial.destroy
    render nothing: true
  end

  protected

  def partial_params
    params[:partial].permit!
  end

  def set_partial
    @partial = Pulitzer::Partial.find(params[:id])
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
pulitzer-0.12.3 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.12.2 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.12.1 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.12.0 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.11.3 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.11.2 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.11.1 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.11.0 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.10.3 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.10.2 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.10.1 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.10.0 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.14 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.13 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.11 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.10 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.9 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.8 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.7 app/controllers/pulitzer/partials_controller.rb
pulitzer-0.5.6 app/controllers/pulitzer/partials_controller.rb