Files
growstuff/app/controllers/plant_parts_controller.rb
Daniel O'Connor b77df88df9 Issues/1475: Ensure we have pagination (#3193)
* Paginate, 100 at a time

* Limited i18n

* Paginate roles

* Pagination

* Pagination

* i18n and pagination

* Paginate alternate names

* Silence code climate

* Rewrite coverage as a feature

* Remove coverage in favour of crops/scientific_name_spec

* Add missing admin link

* Rewrite coverage as feature

* Rewrite coverage

---------

Co-authored-by: Brenda Wallace <brenda@wallace.net.nz>
2024-01-21 14:19:36 +10:30

45 lines
813 B
Ruby

# frozen_string_literal: true
class PlantPartsController < ApplicationController
load_and_authorize_resource
respond_to :html, :json
responders :flash
def index
@plant_parts = PlantPart.all.order(:name).paginate(page: params[:page], per_page: 100)
respond_with(@plant_parts)
end
def show
respond_with(@plant_part)
end
def new
@plant_part = PlantPart.new
respond_with(@plant_part)
end
def edit; end
def create
@plant_part = PlantPart.create(plant_part_params)
respond_with(@plant_part)
end
def update
@plant_part.update(plant_part_params)
respond_with(@plant_part)
end
def destroy
@plant_part.destroy
respond_with(@plant_part)
end
private
def plant_part_params
params.require(:plant_part).permit(:name, :slug)
end
end