Sha256: 8c89f44540bc9fc2c5e38a28e49f69689447686627119cebfb356f3c8b13a00c

Contents?: true

Size: 691 Bytes

Versions: 49

Compression:

Stored size: 691 Bytes

Contents

class CardsController < ApplicationController

  def index
    load_cards
  end

  def show
    load_cards
    load_card
  end

  def new
    load_cards
    build_card
  end

  def create
    load_cards
    build_card
    if @card.save
      redirect_to card_path(@card)
    else
      render 'new'
    end
  end

  private

  def card_scope
    Card.all
  end

  def load_cards
    @cards ||= card_scope.to_a
  end

  def load_card
    @card ||= card_scope.find(params[:id])
  end

  def build_card
    @card ||= card_scope.build
    @card.attributes = card_params
  end

  def card_params
    note_params = params[:card]
    note_params ? note_params.permit(:title, :body) : {}
  end

end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
upjs-rails-0.14.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.13.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.5 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.4 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.3 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.2 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.12.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.11.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.11.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.5 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.4 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.3 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.2 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.10.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.9.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.9.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.8.2 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.8.1 spec_app/app/controllers/cards_controller.rb