Advertisement
Foxscotch

Untitled

Nov 11th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.53 KB | None | 0 0
  1. class ArticlesController < ApplicationController
  2.   def index
  3.     # Instance variables are available in the view (template)
  4.     @articles = Article.all
  5.   end
  6.  
  7.   def show
  8.     @article = Article.find(params[:id])
  9.   end
  10.  
  11.   def new
  12.   end
  13.  
  14.   def create
  15.     @article = Article.new(article_params)
  16.     @article.save
  17.     redirect_to @article
  18.   end
  19.  
  20.   private
  21.     def article_params
  22.       # "Strong params" stuff, basically specifying what parameters are allowed
  23.       params.require(:article).permit(:title, :text)
  24.     end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement