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
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/model_info/models_controller.rb', line 18 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
41 42 43 44 |
# File 'app/controllers/model_info/models_controller.rb', line 41 def destroy @model_class.find(params[:model_object_id]).destroy redirect_back(fallback_location: request.referrer) end |
#edit ⇒ Object
28 |
# File 'app/controllers/model_info/models_controller.rb', line 28 def edit; end |
#index ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/model_info/models_controller.rb', line 8 def index @model_class = params[:model_class] || @model_array&.first @page = params[:page] || 1 @model_pagination = @model_class.constantize.page(@page).per(10) end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/model_info/models_controller.rb', line 14 def new @model_data = @model_class.new end |
#show ⇒ Object
30 |
# File 'app/controllers/model_info/models_controller.rb', line 30 def show; end |
#update ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/model_info/models_controller.rb', line 32 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 |