Class: Dust::PostsController

Inherits:
AuthenticationController show all
Defined in:
app/controllers/dust/posts_controller.rb

Instance Method Summary collapse

Methods inherited from AuthenticationController

#not_authenticated, #permission_denied, #try_return_to_previous_page

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/dust/posts_controller.rb', line 20

def create
  @post = Post.new_with_menu_item(params[:dust_post])

  if @post.save
    redirect_to front_end_post_path(@post.slug), notice: 'Post was successfully created.'
  else
    render action: "new"
  end
end

#destroyObject



40
41
42
43
44
45
# File 'app/controllers/dust/posts_controller.rb', line 40

def destroy
  @post = Post.find(params[:id])
  @post.destroy

  redirect_to posts_url
end

#editObject



16
17
18
# File 'app/controllers/dust/posts_controller.rb', line 16

def edit
  @post = Post.find(params[:id])
end

#indexObject



8
9
10
# File 'app/controllers/dust/posts_controller.rb', line 8

def index
  @posts = Post.all
end

#newObject



12
13
14
# File 'app/controllers/dust/posts_controller.rb', line 12

def new
  @post = Post.new_with_menu_item
end

#updateObject



30
31
32
33
34
35
36
37
38
# File 'app/controllers/dust/posts_controller.rb', line 30

def update
  @post = Post.find(params[:id])

  if @post.update_attributes(params[:dust_post])
    redirect_to front_end_post_path(@post.slug), notice: 'Post was successfully updated.'
  else
    render action: "edit"
  end
end