Sha256: ac690e9d206b55bfc02f8b7d95e7370b38d516e7f0a53f2418e2ca7ff023fffe
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
require_dependency "bongo/application_controller" module Bongo class ArticlesController < ApplicationController before_action :authenticate_user!, except: [:index, :show] before_action :set_article, only: [:show, :edit, :update, :destroy] def index @articles = Article.all.order(publish_at: :desc) end def show end def new @article = Article.new end def edit end def create @article = Article.new(article_params) 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 set_article @article = Article.find(params[:id]) end def article_params params.require(:article).permit(:title, :text, :publish_at) end end end
Version data entries
4 entries across 4 versions & 1 rubygems