Class: Admin::Blog::BlogsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/blog/blogs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/admin/blog/blogs_controller.rb', line 18

def create
  @blog.save!
  flash[:success] = 'Blog created'
  redirect_to :action => :edit, :id => @blog
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to create Blog'
  render :action => :new
end

#destroyObject



36
37
38
39
40
# File 'app/controllers/admin/blog/blogs_controller.rb', line 36

def destroy
  @blog.destroy
  flash[:success] = 'Blog deleted'
  redirect_to :action => :index
end

#editObject



14
15
16
# File 'app/controllers/admin/blog/blogs_controller.rb', line 14

def edit
  render
end

#indexObject



6
7
8
# File 'app/controllers/admin/blog/blogs_controller.rb', line 6

def index
  @blogs = @site.blogs.page(params[:page])
end

#newObject



10
11
12
# File 'app/controllers/admin/blog/blogs_controller.rb', line 10

def new
  render
end

#updateObject



27
28
29
30
31
32
33
34
# File 'app/controllers/admin/blog/blogs_controller.rb', line 27

def update
  @blog.update_attributes!(blog_params)
  flash[:success] = 'Blog updated'
  redirect_to :action => :edit, :id => @blog
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to update Blog'
  render :action => :edit
end