Sha256: 16a2f7204d9ba38379587e57d42e6976452252e06a82ccccfb7bca3c96e196b8
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 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 @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.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activity_notification-0.0.10 | spec/rails_app/app/controllers/articles_controller.rb |
activity_notification-0.0.9 | spec/rails_app/app/controllers/articles_controller.rb |