Class: Monologue::Admin::PostsController
- Inherits:
-
BaseController
- Object
- BaseController
- Monologue::Admin::PostsController
- Defined in:
- app/controllers/monologue/admin/posts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#preview ⇒ Object
Preview a post without saving.
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 25 def create @post = Monologue::Post.new(params[:post]) @post.user_id = monologue_current_user.id if @post.save prepare_flash_and_redirect_to_edit() else render :new end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 46 def destroy post = Monologue::Post.find(params[:id]) if post.destroy redirect_to admin_posts_path, notice: I18n.t("monologue.admin.posts.delete.removed") else redirect_to admin_posts_path, alert: I18n.t("monologue.admin.posts.delete.failed") end end |
#edit ⇒ Object
35 36 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 35 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 6 def index @posts = Monologue::Post.default end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 10 def new @post = Monologue::Post.new end |
#preview ⇒ Object
Preview a post without saving.
15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 15 def preview # mockup our models for preview. @post = Monologue::Post.new(params[:post]) @post.user_id = monologue_current_user.id @post.published_at = Time.zone.now # render it exactly as it would display when live. render "/monologue/posts/show", layout: Monologue.layout || "/layouts/monologue/application" end |
#update ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/monologue/admin/posts_controller.rb', line 38 def update if @post.update_attributes(params[:post]) prepare_flash_and_redirect_to_edit() else render :edit end end |