Class: ExpansionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/expansions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#_edition_exists, #after_sign_in_path_for, #deny_access, #expansion_exists, #fill_platforms, #game_exists, #game_maker_only, #has_query, #ignore_referral_spam, #reviewer_only, #work_exists, #xhr_only

Instance Method Details

#createObject


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/expansions_controller.rb', line 24

def create
	@edition = Edition.friendly.find(params[:edition_id])

	@expansion = Expansion.new(expansion_params)
	@expansion.edition = @edition

	if @expansion.save
		flash[:notice] = "DLC/Expansion was added successfully."
		redirect_to [@edition, @expansion]
	else
		render 'new'
	end

end

#destroyObject


56
57
58
59
60
61
62
63
# File 'app/controllers/expansions_controller.rb', line 56

def destroy
	@expansion = Expansion.friendly.find(params[:id])
	edition = @expansion.edition
	title = @expansion.title
	@expansion.destroy
	flash[:notice] = "Expansion #{title} was deleted."
	redirect_to edition
end

#editObject


42
43
44
45
# File 'app/controllers/expansions_controller.rb', line 42

def edit
	@expansion = Expansion.friendly.find(params[:id])
	@edition = @expansion.edition
end

#newObject


38
39
40
41
# File 'app/controllers/expansions_controller.rb', line 38

def new
	@edition = Edition.friendly.find(params[:edition_id])
	@expansion = @edition.expansions.build
end

#showObject


17
18
19
20
21
22
23
# File 'app/controllers/expansions_controller.rb', line 17

def show
	@expansion = Expansion.friendly.find(params[:id])
	@edition = @expansion.edition
	@description = GitHub::Markdown.render_gfm(@expansion.description.present? ? @expansion.description : "").html_safe
	@user_shelves = GameShelf.user_shelves(current_user.id) if current_user
	params[:platform] = @edition.platform_id.to_s
end

#updateObject


46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/expansions_controller.rb', line 46

def update
	@expansion = Expansion.friendly.find(params[:id])
	@edition = @expansion.edition
	if @expansion.update_attributes(expansion_params)
		flash[:notice] = "Your changes were saved!"
		redirect_to [@edition, @expansion]
	else
		render 'edit'
	end
end