Class: Stiki::SpacesController
Instance Method Summary
collapse
#has_access, #stiki_routes, #user_name
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/stiki/spaces_controller.rb', line 15
def create
@space = Space.new(params[:space])
if Stiki.authenticate_by == :devise
author = Author.new
author.user = self.send( "current_#{Stiki::Helper.user_model_name}".to_sym )
author.creator = true
@space.authors << author
end
unless @space.save
flash[:error] = "Error creating new Space"
end
redirect_to stiki_routes.spaces_path
end
|
#destroy ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/stiki/spaces_controller.rb', line 52
def destroy
@space = Space.find( params[:id] )
if @space.pages.size > 0
flash[:error] = "Cannot delete a Wiki Space that has Wiki Pages"
else
@space.destroy
flash[:notice] = "The Space #{@space.name} has been deleted"
end
redirect_to stiki_routes.spaces_path
end
|
#edit ⇒ Object
def show handled by PageController#index
11
12
13
|
# File 'app/controllers/stiki/spaces_controller.rb', line 11
def edit
@space = Space.find(params[:id])
end
|
#index ⇒ Object
5
6
7
8
|
# File 'app/controllers/stiki/spaces_controller.rb', line 5
def index
@spaces = Space.all
@space = Space.new
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/stiki/spaces_controller.rb', line 32
def update
@space = Space.find(params[:id])
@space.attributes = params[:space]
if Stiki.authenticate_by == :devise
author = Author.new
author.user = self.send( "current_#{Stiki::Helper.user_model_name}".to_sym )
@space.authors << author
end
if @space.save
flash[:notice] = "Space Updated"
redirect_to stiki_routes.spaces_path
else
flash[:error] = "Error creating new Space"
render :template => 'stiki/spaces/edit'
end
end
|