Class: PersonalBlog::PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PersonalBlog::PostsController
- Defined in:
- app/controllers/personal_blog/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
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 31 def create @post = Post.new(post_params) if @post.save redirect_to @post, notice: 'Post was successfully created.' else render :new end end |
#destroy ⇒ Object
DELETE /posts/1
51 52 53 54 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 51 def destroy @post.destroy redirect_to posts_url, notice: 'Post was successfully destroyed.' end |
#edit ⇒ Object
GET /posts/1/edit
27 28 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 27 def edit end |
#index ⇒ Object
GET /posts
9 10 11 12 13 14 15 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 9 def index if params[:tag] @posts = Post.tagged_with(params[:tag]) else @posts = Post.all end end |
#new ⇒ Object
GET /posts/new
22 23 24 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 22 def new @post = Post.new end |
#show ⇒ Object
GET /posts/1
18 19 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 18 def show end |
#update ⇒ Object
PATCH/PUT /posts/1
42 43 44 45 46 47 48 |
# File 'app/controllers/personal_blog/posts_controller.rb', line 42 def update if @post.update(post_params) redirect_to @post, notice: 'Post was successfully updated.' else render :edit end end |