Class: PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- PostsController
- Defined in:
- tmp/mongoid-demo/rails/app/controllers/posts_controller.rb,
tmp/mongoid-demo/rails-api/app/controllers/posts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /posts.
-
#destroy ⇒ Object
DELETE /posts/1.
-
#edit ⇒ Object
GET /posts/1/edit.
-
#index ⇒ Object
GET /posts.
-
#new ⇒ Object
GET /posts/new.
-
#show ⇒ Object
GET /posts/1.
-
#update ⇒ Object
PATCH/PUT /posts/1.
Instance Method Details
#create ⇒ Object
POST /posts
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 26 def create @post = Post.new(post_params) respond_to do |format| if @post.save format.html { redirect_to @post, notice: 'Post was successfully created.' } format.json { render :show, status: :created, location: @post } else format.html { render :new } format.json { render json: @post.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /posts/1
56 57 58 59 60 61 62 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 56 def destroy @post.destroy respond_to do |format| format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /posts/1/edit
21 22 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 21 def edit end |
#index ⇒ Object
GET /posts
6 7 8 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 6 def index @posts = Post.all end |
#new ⇒ Object
GET /posts/new
16 17 18 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 16 def new @post = Post.new end |
#show ⇒ Object
GET /posts/1
12 13 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 12 def show end |
#update ⇒ Object
PATCH/PUT /posts/1
42 43 44 45 46 47 48 49 50 51 52 |
# File 'tmp/mongoid-demo/rails/app/controllers/posts_controller.rb', line 42 def update respond_to do |format| if @post.update(post_params) format.html { redirect_to @post, notice: 'Post was successfully updated.' } format.json { render :show, status: :ok, location: @post } else format.html { render :edit } format.json { render json: @post.errors, status: :unprocessable_entity } end end end |