Class: Admin::Blog::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/blog/posts_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#find_tags, #load_assets

Methods included from BlogHelper

#blog_archive_list, #blog_post_teaser, #next_or_previous?

Instance Method Details

#createObject

create method for creating blogbosts parameters: title, body, cached_slug



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/admin/blog/posts_controller.rb', line 41

def create
  # if the position field exists, set this object as last object, given the conditions of this class.

  #Creating BlogPost model object with the params blog_post
  @blog_post = BlogPost.new(params[:blog_post])

	@blog_post.user_id = current_user ? current_user.id: 0
  @blog_post.body = params[:blog_post][:body]                  #assigning params[:content] as blog_post body
  @blog_post.cached_slug = params[:blog_post][:cached_slug]          #assigning params[:content1] as blog_post cached_slug


  if @blog_post.save
    redirect_to admin_blog_root_path
  else
    render 'new'
  end
end

#uncategorizedObject

assigning all uncategorized blog posts to @blog_posts



60
61
62
63
64
65
66
# File 'app/controllers/admin/blog/posts_controller.rb', line 60

def uncategorized
  @blog_posts = BlogPost.uncategorized.paginate({
    :page => params[:page],
    :per_page => BlogPost.per_page
  })
render 'index'
end