Class: ModelClassNamePluralController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ModelClassNamePluralController
- Defined in:
- lib/generators/pure_admin/scaffold/templates/models_controller.rb
Overview
Controller for ModelClassName
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 26 def create respond_to do |format| if @model_instance_singular.save format.html do redirect_to @model_instance_singular, notice: 'ModelClassName was successfully created.' end else format.html do @title = 'New ModelClassName' render action: :new end end end end |
#destroy ⇒ Object
60 61 62 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 60 def destroy # Place your destroy logic here end |
#edit ⇒ Object
41 42 43 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 41 def edit @title = "Edit #{@model_instance_singular}" end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 6 def index @title = 'ModelClassNamePlural' @model_instance_collection = apply_scopes(@model_instance_collection) respond_with(@model_instance_collection) do |format| format.html do @model_instance_collection = @model_instance_collection.page(params[:page]) render partial: 'table' if request.xhr? end end end |
#new ⇒ Object
22 23 24 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 22 def new @title = 'New ModelClassName' end |
#show ⇒ Object
18 19 20 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 18 def show @title = @model_instance_singular end |
#update ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/generators/pure_admin/scaffold/templates/models_controller.rb', line 45 def update respond_to do |format| if @model_instance_singular.update(model_instance_singular_params) format.html do redirect_to @model_instance_singular, notice: 'ModelClassName was successfully updated.' end else format.html do @title = "Edit #{@model_instance_singular}" render action: :edit end end end end |