Class: Storytime::Dashboard::CustomPostsController
- Inherits:
-
BlogPostsController
- Object
- ApplicationController
- Storytime::DashboardController
- PostsController
- BlogPostsController
- Storytime::Dashboard::CustomPostsController
- Defined in:
- app/controllers/storytime/dashboard/custom_posts_controller.rb
Instance Method Summary collapse
Methods inherited from BlogPostsController
Methods inherited from PostsController
#destroy, #edit, #index, #update
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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/storytime/dashboard/custom_posts_controller.rb', line 12 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 |