Class: Phcscriptcdnpro::Scriptcdn::AuthorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #new_login_url, #require_user

Instance Method Details

#createObject

POST Author



30
31
32
33
34
35
36
37
38
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 30

def create
	@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
	@scriptcdn_author = @scriptcdn_main.authors.create(scriptcdn_author_params)
	if @scriptcdn_author.save
		redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully created.'
		else
			render :new
	end
end

#destroyObject

DELETE Author



50
51
52
53
54
55
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 50

def destroy
	@scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
	@scriptcdn_author = @scriptcdn_main.authors.find(params[:id])
	@scriptcdn_author.destroy
	redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully destroyed.'
end

#editObject

Edit Author



24
25
26
27
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 24

def edit
	scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
	@scriptcdn_author = scriptcdn_main.authors.find(params[:id])
end

#indexObject

Author Index



12
13
14
15
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 12

def index
	scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
	@scriptcdn_authors = scriptcdn_main.authors
end

#newObject

New Author



18
19
20
21
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 18

def new
	scriptcdn_main = Scriptcdn::Main.find(params[:main_id])
	@scriptcdn_author = scriptcdn_main.authors.build
end

#updateObject

PATCH/PUT Author



41
42
43
44
45
46
47
# File 'app/controllers/phcscriptcdnpro/scriptcdn/authors_controller.rb', line 41

def update
	if @scriptcdn_author.update(scriptcdn_author_params)
		redirect_to scriptcdn_main_authors_url, notice: 'Author was successfully updated.'
		else
			render :edit
	end
end