1
0
Fork 0
dokkan-data-rails/app/controllers/cards_controller.rb

55 lines
1 KiB
Ruby
Raw Normal View History

2015-10-06 13:55:12 -04:00
class CardsController < ApplicationController
before_action :set_card, only: [:show, :edit, :update, :destroy]
def index
@cards = Card.all
end
def show
end
def new
@card = Card.new
end
def create
@card = Card.new(card_params)
if @card.save
redirect_to cards_path, notice: 'Card was created'
else
render :new
end
end
def edit
end
def update
if @card.update(card_params)
redirect_to cards_path, notice: 'Card was updated'
else
render :edit
end
end
def destroy
@card.destroy
redirect_to cards_path, notice: 'Card was deleted'
end
private
def card_params
params.require(:card).permit(:prefix, :character_id, :rarity_id, :type_id,
:leader_skill_id, :passive_skill_id,
:super_attack_id, :dokkan_id, :gameid,
2015-10-08 11:45:05 -04:00
:awaken_type_id, :dokkan_id, link_ids: [])
2015-10-06 13:55:12 -04:00
end
def set_card
@card = Card.find(params[:id])
end
end