1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00
الملفات
postal/app/controllers/address_endpoints_controller.rb
2024-02-10 17:18:23 +00:00

48 أسطر
1.2 KiB
Ruby

# frozen_string_literal: true
class AddressEndpointsController < ApplicationController
include WithinOrganization
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
before_action { params[:id] && @address_endpoint = @server.address_endpoints.find_by_uuid!(params[:id]) }
def index
@address_endpoints = @server.address_endpoints.order(:address).to_a
end
def new
@address_endpoint = @server.address_endpoints.build
end
def create
@address_endpoint = @server.address_endpoints.build(safe_params)
if @address_endpoint.save
flash[:notice] = params[:return_notice] if params[:return_notice].present?
redirect_to_with_json [:return_to, [organization, @server, :address_endpoints]]
else
render_form_errors "new", @address_endpoint
end
end
def update
if @address_endpoint.update(safe_params)
redirect_to_with_json [organization, @server, :address_endpoints]
else
render_form_errors "edit", @address_endpoint
end
end
def destroy
@address_endpoint.destroy
redirect_to_with_json [organization, @server, :address_endpoints]
end
private
def safe_params
params.require(:address_endpoint).permit(:address)
end
end