Sha256: 7abd24349c1ce154062b920ab9961490e0c16e4422624cf67cdc9a9d8f196a6e
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] # GET /posts def index @posts = Post.all end # GET /posts/1 def show @post = Post.find(params[:id]) end # GET /posts/new def new @post = Post.new end # GET /posts/1/edit def edit 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 # PATCH/PUT /posts/1 def update if @post.update(post_params) redirect_to @post, notice: 'Post was successfully updated.' else render action: 'edit' end end # DELETE /posts/1 def destroy @post.destroy redirect_to posts_url, notice: 'Post was successfully destroyed.' end def with_exception sleep rand(10) / 1000.0 raise 'Exception' end def skipped render text: 'skipped' 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, :body) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
app_monit_rails-0.0.6 | spec/dummy/app/controllers/posts_controller.rb |
app_monit_rails-0.0.5 | spec/dummy/app/controllers/posts_controller.rb |