Class: Notee::PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Notee::PostsController
- Defined in:
- app/controllers/notee/posts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /posts.
-
#destroy ⇒ Object
DELETE /posts/1.
-
#index ⇒ Object
GET /posts.
- #notee ⇒ Object
-
#show ⇒ Object
GET /posts/1.
-
#update ⇒ Object
PATCH/PUT /posts/1.
Instance Method Details
#create ⇒ Object
POST /posts
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/notee/posts_controller.rb', line 25 def create @post = Post.new(post_params) respond_to do |format| if @post.save format.json { render json: @post, status: 200 } else format.json { render json: @post.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /posts/1
48 49 50 51 |
# File 'app/controllers/notee/posts_controller.rb', line 48 def destroy @post.destroy render json: { status: 'success'} end |
#index ⇒ Object
GET /posts
14 15 16 17 |
# File 'app/controllers/notee/posts_controller.rb', line 14 def index @posts = Post.all render json: { status: 'success', posts: @posts} end |
#notee ⇒ Object
10 11 |
# File 'app/controllers/notee/posts_controller.rb', line 10 def notee end |
#show ⇒ Object
GET /posts/1
20 21 22 |
# File 'app/controllers/notee/posts_controller.rb', line 20 def show render json: { status: 'success', post: @post} end |
#update ⇒ Object
PATCH/PUT /posts/1
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/notee/posts_controller.rb', line 37 def update respond_to do |format| if @post.update(post_params) format.json { render json: @post, status: 200 } else format.json { render json: @post.errors, status: :unprocessable_entity } end end end |