Sha256: 7eef3f63e6e79e8f1e568dd99265677dda18fdad65e2df5a9b17d56eac282cfc
Contents?: true
Size: 1.01 KB
Versions: 26
Compression:
Stored size: 1.01 KB
Contents
# Used to test #authorize!, #load_and_authorize & load_and_authorize! class ArticlesController < ApplicationController load_and_authorize except: [:index, :show, :new] 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 @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
26 entries across 26 versions & 1 rubygems