Class: BlogEngine::PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BlogEngine::PostsController
- Defined in:
- app/controllers/blog_engine/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
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 24 def create @post = Post.new(post_params) if @post.save redirect_to @post, notice: "Post was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /posts/1
44 45 46 47 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 44 def destroy @post.destroy redirect_to posts_url, notice: "Post was successfully destroyed.", status: :see_other end |
#edit ⇒ Object
GET /posts/1/edit
20 21 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 20 def edit end |
#index ⇒ Object
GET /posts
6 7 8 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 6 def index @posts = Post.all end |
#new ⇒ Object
GET /posts/new
15 16 17 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 15 def new @post = Post.new end |
#show ⇒ Object
GET /posts/1
11 12 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 11 def show end |
#update ⇒ Object
PATCH/PUT /posts/1
35 36 37 38 39 40 41 |
# File 'app/controllers/blog_engine/posts_controller.rb', line 35 def update if @post.update(post_params) redirect_to @post, notice: "Post was successfully updated.", status: :see_other else render :edit, status: :unprocessable_entity end end |