Add support for PG interval field

This commit is contained in:
Alex Sherman 2021-05-05 15:41:30 +05:00
parent f22fc2659f
commit 838522b81a
8 changed files with 47 additions and 43 deletions

View file

@ -40,7 +40,6 @@ module Admin
def create
@price = ::Billing::Price.new(price_params)
if @price.save
flash[:notice] = t('.created')
redirect_to_index
@ -50,7 +49,7 @@ module Admin
end
def update
if @price.update_attributes(price_params)
if @price.update(price_params.compact_blank)
flash[:notice] = t('.updated')
redirect_to_index
else
@ -81,7 +80,9 @@ module Admin
valid_to
]
params.require(:price).permit(*allowed_params)
allowed = params.require(:price).permit(*allowed_params)
allowed[:duration] = ActiveSupport::Duration.build(allowed[:duration].to_i) if allowed[:duration]
allowed
end
def search_params
@ -104,8 +105,7 @@ module Admin
end
def durations
durations = ::Billing::Price::durations
durations.collect { |duration| [duration.sub('mon', 'month'), duration] }
::Billing::Price::durations
end
def statuses