Class: Admin::BlogPostsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/templates/controllers/admin/blog_posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
# File 'lib/generators/templates/controllers/admin/blog_posts_controller.rb', line 9

def create
  if @blog_post = BlogPost.create(blog_post_params)
    redirect_to admin_blog_posts_path, notice: "Blog post was created successfully"
  else
    render :new
  end
end

#editObject



21
22
# File 'lib/generators/templates/controllers/admin/blog_posts_controller.rb', line 21

def edit
end

#indexObject



17
18
19
# File 'lib/generators/templates/controllers/admin/blog_posts_controller.rb', line 17

def index
  @blog_posts = BlogPost.all
end

#newObject



5
6
7
# File 'lib/generators/templates/controllers/admin/blog_posts_controller.rb', line 5

def new
  @blog_post = BlogPost.new
end

#updateObject



24
25
26
27
28
29
30
# File 'lib/generators/templates/controllers/admin/blog_posts_controller.rb', line 24

def update
  if @blog_post.update(blog_post_params)
    redirect_to @blog_post, notice: "Blog post has been updated successfully"
  else
    render :edit
  end
end