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
49
50
51
52
53
54
55
|
# File 'lib/coupler/extensions/transformers.rb', line 4
def self.registered(app)
app.get "/transformers" do
@transformers = Models::Transformer.all
erb :'transformers/index'
end
app.post "/transformers/preview" do
@transformer = Models::Transformer.new(params[:transformer])
erb(:'transformers/preview', :layout => false)
end
app.get "/transformers/new" do
@transformer = Models::Transformer.new
erb :'transformers/new'
end
app.get '/transformers/:id' do
@transformer = Models::Transformer[:id => params[:id]]
erb :'transformers/show'
end
app.get "/transformers/:id/edit" do
@transformer = Models::Transformer[:id => params[:id]]
erb :'transformers/edit'
end
app.post "/transformers" do
@transformer = Models::Transformer.new(params[:transformer])
if @transformer.save
redirect "/transformers"
else
erb :'transformers/new'
end
end
app.put '/transformers/:id' do
@transformer = Models::Transformer[:id => params[:id]]
@transformer.set(params[:transformer])
if @transformer.valid?
@transformer.save
redirect '/transformers'
else
erb :'transformers/edit'
end
end
app.delete '/transformers/:id' do
@transformer = Models::Transformer[:id => params[:id]]
@transformer.destroy
redirect '/transformers'
end
end
|