Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticlesController < ApplicationController
- def new
- @article = Article.new
- end
- def create
- @article = Article.new(article_params)
- if @article.save
- redirect_to @article
- else
- render 'new'
- end
- end
- def show
- @article = Article.find(params[:id])
- @owner = 'Armand'
- end
- def edit
- @article = Article.find(params[:id])
- end
- def update
- @article = Article.find(params[:id])
- if Article.update(article_params)
- redirect_to @article
- else
- render 'edit'
- end
- end
- def index
- @articles = Article.all
- end
- private
- def article_params
- params.require(:article).permit(:title, :text)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement