Skip to content

Instantly share code, notes, and snippets.

@Evanto
Created May 5, 2017 15:13
Show Gist options
  • Save Evanto/14c2aef1d16ab258458685e2428cbbba to your computer and use it in GitHub Desktop.
Save Evanto/14c2aef1d16ab258458685e2428cbbba to your computer and use it in GitHub Desktop.
class CardsController < ApplicationController
# before_action :find_card, only: [:show, :edit, :update, :destroy]
def index
@cards = Card.all
end
def show
end
def index
end
def new
@cards = Card.new
end
def create
@cards = Card.new(card_params)
if @cards.save!
redirect_to cards_path
else
render :new, notice: "Эй!"
end
end
def destroy
@cards.delete
redirect_to cards_path
end
def edit
end
#def update
# if @card.update(card_params)
# redirect_to cards_path
# else
#render "edit"
# end
# end
def find
@cards = Card.find(params[:id])
end
private
def card_params
params.require(:card).permit(:original_text, :translated_text, :review_date)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment