Class: GeoLabels::LabelsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- GeoLabels::LabelsController
- Includes:
- SharedTemplateAndInstanceMethods
- Defined in:
- app/controllers/geo_labels/labels_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 21 def create @record = record_class.new record_params :create, @record if @record.save redirect_to @record, status: :see_other else render action: 'new' end end |
#destroy ⇒ Object
51 52 53 54 55 56 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 51 def destroy @record = record_class.find params[:id] :destroy, @record @record.destroy redirect_to record_class, status: :see_other end |
#edit ⇒ Object
36 37 38 39 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 36 def edit @record = record_class.find(params[:id]) :edit, @record end |
#index ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 8 def index :index, record_class @q = record_class.ransack query @q.sorts = 'name asc' if @q.sorts.empty? @records = @q.result.page(params[:page]).per(100) respond_with(@records) end |
#new ⇒ Object
16 17 18 19 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 16 def new @record = record_class.new(parent_id: params[:parent_id]) :create, @record end |
#show ⇒ Object
31 32 33 34 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 31 def show @record = record_class.find params[:id] :show, @record end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/geo_labels/labels_controller.rb', line 41 def update @record = record_class.find params[:id] :edit, @record if @record.update record_params redirect_to @record, status: :see_other else render action: 'edit' end end |