Sha256: 6e19a342816abc39a662484ddd1b157fc5d48c93d38d67c6ec6c452ccd4e5c26
Contents?: true
Size: 999 Bytes
Versions: 15
Compression:
Stored size: 999 Bytes
Contents
class ArticlesController < ApplicationController load_and_authorize only: [:edit] require_login only: [:update] def index authorize_and_load_records! end def show load_and_authorize! end def new authorize! @article = Article.new end def edit end def create require_login! @article = Article.new(article_params) @article.user = current_user if @article.save redirect_to @article, notice: 'Article was successfully created.' else render :new end end def update @article = Article.find(params[:id]) if @article.update(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render :edit end end def destroy @article = Article.find(params[:id]) @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end private def article_params params.require(:article).permit(:title, :content) end end
Version data entries
15 entries across 15 versions & 1 rubygems