Sha256: 4160da407decdeb455f80253c6284ed594ea13ee2056f107ef41374e2cfcc38b
Contents?: true
Size: 639 Bytes
Versions: 10
Compression:
Stored size: 639 Bytes
Contents
class PostsController < ApplicationController # GET /posts def index @posts = Post.all end # GET /posts/new def new @post = Post.new end # POST /posts def create @post = Post.new(post_params) if @post.save redirect_to @post, notice: 'Post was successfully created.' else render action: 'new' end end private # Use callbacks to share common setup or constraints between actions. def set_post @post = Post.find(params[:id]) end # Only allow a trusted parameter "white list" through. def post_params params.require(:post).permit(:title) end end
Version data entries
10 entries across 10 versions & 1 rubygems