Class: ModelInfo::ModelsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ModelInfo::ModelsController
- Defined in:
- app/controllers/model_info/models_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #display ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/model_info/models_controller.rb', line 17 def create @model_data = @model_class.new(permit_params) if @model_data.save redirect_to model_show_path(model_class: @model_class, model_object_id: @model_data.id) else flash[:error] = @model_data.errors. redirect_back(fallback_location: request.referrer) end end |
#destroy ⇒ Object
42 43 44 45 |
# File 'app/controllers/model_info/models_controller.rb', line 42 def destroy @model_class.find(params[:model_object_id]).destroy redirect_back(fallback_location: request.referrer) end |
#display ⇒ Object
8 9 10 11 |
# File 'app/controllers/model_info/models_controller.rb', line 8 def display @model_class, @page = params[:model_class] || @model_array.try(:first), params[:page] || 1 @model_pagination = @model_class.constantize.page(@page).per(10) end |
#edit ⇒ Object
27 28 |
# File 'app/controllers/model_info/models_controller.rb', line 27 def edit end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/model_info/models_controller.rb', line 13 def new @model_data = @model_class.new end |
#show ⇒ Object
30 31 |
# File 'app/controllers/model_info/models_controller.rb', line 30 def show end |
#update ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/model_info/models_controller.rb', line 33 def update if @model_data.update(permit_params) redirect_to model_show_path(model_class: @model_class, model_object_id: @model_data.id) else flash[:error] = @model_data.errors. redirect_back(fallback_location: request.referrer) end end |