Class: Tramway::SingletonsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Tramway::SingletonsController
- Defined in:
- app/controllers/tramway/singletons_controller.rb
Instance Method Summary collapse
Methods included from RecordRoutesHelper
#edit_record_path, #new_record_path, #record_path, #records_path
Methods included from Filtering
#date_filter, #filtering, #list_filtering, #list_filtering_dates, #list_filtering_select
Methods included from AuthManagement
#authenticate_user!, #current_user, #sign_in, #sign_out, #signed_in?
Methods included from ClassNameHelpers
#decorator_class_name, #form_class_name, #model_class_name
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/tramway/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/singletons_controller.rb', line 15 def edit @singleton_form = admin_form_class.new model_class.first end |
#show ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/tramway/singletons_controller.rb', line 5 def show if model_class.first.present? @singleton = decorator_class.decorate model_class.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/singletons_controller.rb', line 28 def update @singleton_form = admin_form_class.new model_class.first if @singleton_form.submit params[:singleton] redirect_to params[:redirect] || singleton_path(model: params[:model]) else render :edit end end |