Class: Tramway::Admin::SingletonsController
Instance Method Summary
collapse
#edit_record_path, #new_record_path, #record_path, #records_path
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/controllers/tramway/admin/singletons_controller.rb', line 19
def create
@singleton_form = admin_form_class.new model_class.new
if @singleton_form.submit params[:singleton]
redirect_to params[:redirect] || singleton_path(model: params[:model])
else
render :edit
end
end
|
#edit ⇒ Object
15
16
17
|
# File 'app/controllers/tramway/admin/singletons_controller.rb', line 15
def edit
@singleton_form = admin_form_class.new model_class.active.first
end
|
#show ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'app/controllers/tramway/admin/singletons_controller.rb', line 5
def show
if model_class.active.first.present?
@singleton = decorator_class.decorate model_class.active.first
else
@singleton_form = admin_form_class.new model_class.new
render :new
nil
end
end
|
#update ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'app/controllers/tramway/admin/singletons_controller.rb', line 28
def update
@singleton_form = admin_form_class.new model_class.active.first
if @singleton_form.submit params[:singleton]
redirect_to params[:redirect] || singleton_path(model: params[:model])
else
render :edit
end
end
|