Class: Admin::Posts::TitlesController

Inherits:
ApplicationController show all
Defined in:
lib/ecrire/app/controllers/admin/posts/titles_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#posts

Methods inherited from ApplicationController

#current_user, #signed_in?, #url

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
# File 'lib/ecrire/app/controllers/admin/posts/titles_controller.rb', line 14

def create
  @post = Admin::Post.find(params[:post_id])
  @title = @post.titles.new(title_params)
  if @title.save
    redirect_to admin_post_titles_path(@title.post) and return
  end

  render 'index'
end

#indexObject



5
6
7
8
9
10
11
12
# File 'lib/ecrire/app/controllers/admin/posts/titles_controller.rb', line 5

def index
  @post = Admin::Post.find(params[:post_id])
  if @post.published?
    @title = @post.titles.new
  else
    @title = @post.titles.first
  end
end

#updateObject



24
25
26
27
28
29
30
31
# File 'lib/ecrire/app/controllers/admin/posts/titles_controller.rb', line 24

def update
  @title = Admin::Title.find(params[:id])
  if @title.update(title_params)
    redirect_to admin_post_titles_path(@title.post) and return
  end

  render 'index'
end