Sha256: 764bd4e7a538754983c695963bfaa8aeed835d39f58055c5dbe4fdc30531d495
Contents?: true
Size: 866 Bytes
Versions: 11
Compression:
Stored size: 866 Bytes
Contents
class ArticlesController < ApplicationController load_and_authorize only: [:edit] 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 @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 if @article.update(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render :edit end end def destroy @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
11 entries across 11 versions & 1 rubygems