Sha256: 734d78cc8af9c3445dd598376c1d9e5c6cbfb09e6d1c375ddf56d107277b6706
Contents?: true
Size: 1.48 KB
Versions: 5
Compression:
Stored size: 1.48 KB
Contents
class ArticlesController < ApplicationController before_action :authenticate_user!, except: [:index, :show] before_action :set_article, only: [:show, :edit, :update, :destroy] # GET /articles def index @exists_user_notification_routes = respond_to?('user_notification_path') @exists_admin_notification_routes = respond_to?('admin_notification_path') @articles = Article.all.includes(:user) end # GET /articles/1 def show @comment = Comment.new end # GET /articles/new def new @article = Article.new end # GET /articles/1/edit def edit end # POST /articles def create @article = Article.new(article_params) @article.user = current_user if @article.save @article.notify :users redirect_to @article, notice: 'Article was successfully created.' else render :new end end # PATCH/PUT /articles/1 def update if @article.update(article_params) redirect_to @article, notice: 'Article was successfully updated.' else render :edit end end # DELETE /articles/1 def destroy @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_article @article = Article.includes(:user).find(params[:id]) end # Only allow a trusted parameter "white list" through. def article_params params.require(:article).permit(:title, :body) end end
Version data entries
5 entries across 5 versions & 1 rubygems