apps_controller.rb
991 Bytes
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
49
50
class AppsController < ApplicationController
def index
@apps = App.all
end
def show
@app = App.find(params[:id])
@errs = @app.errs.paginate
end
def new
@app = App.new
@app.watchers.build
end
def edit
@app = App.find(params[:id])
@app.watchers.build if @app.watchers.none?
end
def create
@app = App.new(params[:app])
if @app.save
flash[:success] = 'Great success! Configure your app with the API key below'
redirect_to app_path(@app)
else
render :new
end
end
def update
@app = App.find(params[:id])
if @app.update_attributes(params[:app])
flash[:success] = "Good news everyone! '#{@app.name}' was successfully updated."
redirect_to app_path(@app)
else
render :edit
end
end
def destroy
@app = App.find(params[:id])
@app.destroy
flash[:success] = "'#{@app.name}' was successfully destroyed."
redirect_to apps_path
end
end