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
|
# File 'lib/coupler/extensions/connections.rb', line 6
def self.registered(app)
app.get "/connections" do
@connections = Connection.all
erb :'connections/index'
end
app.get "/connections/new" do
@connection = Connection.new
erb :'connections/new'
end
app.get "/connections/:id" do
@connection = Connection[:id => params[:id]]
@resources = @connection.resources
erb :'connections/show'
end
app.post "/connections" do
@connection = Connection.new(params[:connection])
if @connection.save
flash[:notice] = "Connection was successfully created."
redirect "/connections"
else
erb 'connections/new'.to_sym
end
end
app.delete "/connections/:id" do
@connection = Connection[params[:id]]
if @connection.destroy
flash[:notice] = "Connection was successfully deleted."
else
flash[:notice] = "Connection could not be deleted."
flash[:notice_class] = "error"
end
redirect "/connections"
end
end
|