Class: Admin::TitlesController

Inherits:
ApplicationController show all
Defined in:
lib/ecrire/app/controllers/admin/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



11
12
13
14
15
16
17
18
19
# File 'lib/ecrire/app/controllers/admin/titles_controller.rb', line 11

def create
  @title = Admin::Title.new(title_params) do |title|
    title.post = post
  end

  unless @title.save
    render 'errors'
  end
end

#indexObject



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

def index
  if post.draft?
    render 'edit' and return
  end
end

#updateObject



21
22
23
24
25
26
# File 'lib/ecrire/app/controllers/admin/titles_controller.rb', line 21

def update
  @title = Admin::Title.find(params[:id])
  unless @title.update(title_params)
    render 'errors'
  end
end