Sha256: 0e73c6716fac3cde8d90b0bc624c65efdb62c24bd418e92368dcdd12b9ba9e5a

Contents?: true

Size: 667 Bytes

Versions: 23

Compression:

Stored size: 667 Bytes

Contents

module Admin
  class TitlesController < Admin::ApplicationController
    helper_method :post

    def index
      if post.draft?
        render 'edit' and return
      end
    end

    def create
      @title = Admin::Title.new(title_params) do |title|
        title.post = post
      end

      unless @title.save
        render 'errors'
      end
    end

    def update
      @title = Admin::Title.find(params[:id])
      unless @title.update(title_params)
        render 'errors'
      end
    end

    protected

    def title_params
      params.require(:title).permit(:name)
    end

    def post
      @post ||= Post.find(params[:post_id])
    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ecrire-0.31.2 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.31.1 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.31.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.30.3 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.30.2 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.30.1 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.30.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.29.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.28.3 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.28.2 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.28.1 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.28.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.27.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.26.3 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.26.2 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.26.1 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.26.0 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.25.2 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.25.1 lib/ecrire/app/controllers/admin/titles_controller.rb
ecrire-0.25.0 lib/ecrire/app/controllers/admin/titles_controller.rb