Class: FrontEndBuilds::AppsController
Instance Method Summary
collapse
#error!, #respond_with_json
Instance Method Details
#create ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/front_end_builds/apps_controller.rb', line 30
def create
@app = FrontEndBuilds::App.new( app_create_params )
if @app.save
respond_with_json(
{ app: @app.serialize },
location: nil
)
else
respond_with_json(
{ errors: @app.errors },
status: :unprocessable_entity
)
end
end
|
#destroy ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/controllers/front_end_builds/apps_controller.rb', line 61
def destroy
if @app.destroy
respond_with_json(
{ app: { id: @app.id } },
location: nil
)
else
respond_with_json(
{ errors: @app.errors },
status: :unprocessable_entity
)
end
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/front_end_builds/apps_controller.rb', line 7
def index
apps = App.all
respond_with_json({
apps: apps.map(&:serialize),
builds: apps.map(&:recent_builds)
.flat_map(&:to_a)
.map(&:serialize)
})
end
|
#show ⇒ Object
23
24
25
26
27
28
|
# File 'app/controllers/front_end_builds/apps_controller.rb', line 23
def show
respond_with_json({
app: @app.serialize,
builds: @app.recent_builds.map(&:serialize)
})
end
|
#update ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/front_end_builds/apps_controller.rb', line 46
def update
if @app.update_attributes( app_update_params )
respond_with_json(
{ app: @app.serialize },
location: nil
)
else
respond_with_json(
{ errors: @app.errors },
status: :unprocessable_entity
)
end
end
|