Created
July 30, 2018 07:17
-
-
Save hackrio1/64c0b8aef14d3c488b7a8956315bbaca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticlesController < ApplicationController | |
before_action :set_user | |
before_action :set_article, only: [:show, :edit, :update, :destroy] | |
# GET /articles/1 | |
# GET /articles.json | |
def index | |
@articles = @users.articles.all | |
end | |
# GET /articles/1 | |
# GET /articles/1.json | |
def show | |
end | |
# GET /articles/new | |
def new | |
@articles = @users.articles.new | |
end | |
# GET /articles/1/edit | |
def edit | |
end | |
# POST /articles | |
# POST /articles.json | |
def create | |
@articles = @users.articles.new(articles_params) | |
respond_to do |format| | |
if @article.save | |
format.html { redirect_to @article, notice: 'Article was succesfully created.' } | |
format.json { render :show, status: :created, location: @article } | |
else | |
format.html { render.new } | |
format.json { render json: @articles.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment