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.8.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.8 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.7 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.6 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.5 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.4 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.3 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.2 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.7.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.5 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.4 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.3 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.2 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.1 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.6.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.5.0 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.4.4 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.4.3 spec_app/app/controllers/cards_controller.rb
upjs-rails-0.4.2 spec_app/app/controllers/cards_controller.rb