Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArticlesController < ApplicationController
- def index
- # Instance variables are available in the view (template)
- @articles = Article.all
- end
- def show
- @article = Article.find(params[:id])
- end
- def new
- end
- def create
- @article = Article.new(article_params)
- @article.save
- redirect_to @article
- end
- private
- def article_params
- # "Strong params" stuff, basically specifying what parameters are allowed
- params.require(:article).permit(:title, :text)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement