Class: PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PostsController
- Includes:
- BlogController
- Defined in:
- app/controllers/posts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #publish ⇒ Object
- #resource ⇒ Object
- #show ⇒ Object
- #unpublish ⇒ Object
- #update ⇒ Object
Methods included from BlogController
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/posts_controller.rb', line 18 def create @post = Post.new(params[:post]) @post.user = current_user if @post.save redirect_to @post, notice: t('general.form.successfully_created') else render :new end end |
#destroy ⇒ Object
64 65 66 67 68 |
# File 'app/controllers/posts_controller.rb', line 64 def destroy @post.destroy redirect_to posts_path, notice: t('general.form.destroyed') end |
#edit ⇒ Object
29 30 |
# File 'app/controllers/posts_controller.rb', line 29 def edit end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/posts_controller.rb', line 14 def new @post = Post.new(params[:post]) end |
#publish ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/posts_controller.rb', line 40 def publish = {} if @post.publish [:notice] = t('posts.publish.successful') else [:alert] = t('posts.publish.unsuccessful') end redirect_to posts_path, end |
#resource ⇒ Object
70 71 72 |
# File 'app/controllers/posts_controller.rb', line 70 def resource @post end |
#show ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/posts_controller.rb', line 8 def show @home_page_stylesheets = ['home_page/application', 'home_page_blog/posts'] render layout: 'home_page_blog/application' end |
#unpublish ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/posts_controller.rb', line 52 def unpublish = {} if @post.unpublish [:notice] = t('posts.unpublish.successful') else [:alert] = t('posts.unpublish.unsuccessful') end redirect_to posts_path, end |
#update ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/controllers/posts_controller.rb', line 32 def update if @post.update_attributes(params[:post]) redirect_to @post, notice: t('general.form.successfully_updated') else render :edit end end |