We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
49 lines
912 B
Ruby
49 lines
912 B
Ruby
class Admin::GeozonesController < Admin::BaseController
|
|
respond_to :html
|
|
|
|
load_and_authorize_resource
|
|
|
|
def index
|
|
@geozones = Geozone.all.order("LOWER(name)")
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def edit
|
|
end
|
|
|
|
def create
|
|
@geozone = Geozone.new(geozone_params)
|
|
|
|
if @geozone.save
|
|
redirect_to admin_geozones_path
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
if @geozone.update(geozone_params)
|
|
redirect_to admin_geozones_path
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @geozone.safe_to_destroy?
|
|
@geozone.destroy!
|
|
redirect_to admin_geozones_path, notice: t("admin.geozones.delete.success")
|
|
else
|
|
redirect_to admin_geozones_path, flash: { error: t("admin.geozones.delete.error") }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def geozone_params
|
|
params.require(:geozone).permit(:name, :external_code, :census_code, :html_map_coordinates)
|
|
end
|
|
end
|