-
Notifications
You must be signed in to change notification settings - Fork 0
/
stories.rb
48 lines (42 loc) · 1.04 KB
/
stories.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Admin.controllers :stories do
get :index do
@stories = Story.all
render 'stories/index'
end
get :new do
@story = Story.new
@story.map = Map.first
render 'stories/new'
end
post :create do
@story = Story.new(params[:story])
if @story.save
flash[:notice] = 'Story was successfully created.'
redirect url(:stories, :edit, :id => @story.id)
else
render 'stories/new'
end
end
get :edit, :with => :id do
@story = Story.get(params[:id])
render 'stories/edit'
end
put :update, :with => :id do
@story = Story.get(params[:id])
if @story.update(params[:story])
flash[:notice] = 'Story was successfully updated.'
redirect url(:stories, :edit, :id => @story.id)
else
render 'stories/edit'
end
end
delete :destroy, :with => :id do
story = Story.get(params[:id])
if story.destroy
flash[:notice] = 'Story was successfully destroyed.'
else
flash[:error] = 'Unable to destroy Story!'
end
redirect url(:stories, :index)
end
end