Sha256: 17dd0a0fcf94047289d13360d1cd2de2cb91bc2aed6a456a051a40ff7f5188b1

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class PagesController < ApplicationController
  before_action :set_page, only: [:show, :edit, :update, :destroy]

  # GET /pages
  def index
    @pages = Page.all
  end

  # GET /pages/1
  def show
  end

  # GET /pages/new
  def new
    @page = Page.new
  end

  # GET /pages/1/edit
  def edit
  end

  # POST /pages
  def create
    @page = Page.new(page_params)

    if @page.save
      redirect_to @page, notice: 'Page was successfully created.'
    else
      render action: 'new'
    end
  end

  # PATCH/PUT /pages/1
  def update
    if @page.update(page_params)
      redirect_to @page, notice: 'Page was successfully updated.'
    else
      render action: 'edit'
    end
  end

  # DELETE /pages/1
  def destroy
    @page.destroy
    redirect_to pages_url, notice: 'Page was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_page
      @page = Page.find_by_permalink(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def page_params
      params.require(:page).permit(:name, :permalink, :content)
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
valid_route-0.0.4 test/dummy/app/controllers/pages_controller.rb
valid_route-0.0.3 test/dummy/app/controllers/pages_controller.rb
valid_route-0.0.2 test/dummy/app/controllers/pages_controller.rb
valid_route-0.0.1 test/dummy/app/controllers/pages_controller.rb