Class: Storytime::Dashboard::BlogPostsController
- Inherits:
-
PostsController
- Object
- ApplicationController
- Storytime::DashboardController
- PostsController
- Storytime::Dashboard::BlogPostsController
- Defined in:
- app/controllers/storytime/dashboard/blog_posts_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from PostsController
Methods inherited from ApplicationController
#authenticate_user!, #current_user, #setup, #user_signed_in?
Methods included from Concerns::CurrentSite
Methods included from Concerns::ControllerContentFor
#content_for, #content_for?, #view_context
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/storytime/dashboard/blog_posts_controller.rb', line 14 def create @post = current_post_type.new(post_params) @post.blog = Storytime::Blog.friendly.find(params[:blog_id]) @post.user = current_user @post.draft_user_id = current_user.id @post if @post.save @post.create_autosave(post_params.slice(:draft_content)) if params[:preview] == "true" send_subscriber_notifications if @post.published? && post_params[:notifications_enabled] == "1" opts = params[:preview] == "true" ? { preview: true } : {} redirect_to [:edit, :dashboard, @post, opts], notice: I18n.t('flash.posts.create.success') else load_media render :new end end |
#destroy ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/storytime/dashboard/blog_posts_controller.rb', line 35 def destroy @post @post.destroy flash[:notice] = I18n.t('flash.posts.destroy.success') unless request.xhr? respond_with [:dashboard, @post] do |format| format.html{ redirect_to [:dashboard, @post.blog, :blog_page_post_index] } end end |