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.create(title_params)

  respond_to do |format|
    format.html { render 'index' }
    format.js
  end
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? || @post.titles.count > 1
    @title = @post.titles.new
  else
    @title = @post.titles.first
  end
end

#updateObject



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

def update
  @post = Admin::Post.find(params[:post_id])
  @title = Admin::Title.find(params[:id])
  @title.update(title_params)

  respond_to do |format|
    format.html { render 'index' }
    format.js
  end
end