mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Preference to set default_period (#1941)
This commit is contained in:
parent
372b64ffea
commit
26762477a3
12 changed files with 35 additions and 8 deletions
|
@ -2,7 +2,7 @@ module AccountableResource
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include ScrollFocusable
|
||||
include ScrollFocusable, Periodable
|
||||
|
||||
before_action :set_account, only: [ :show, :edit, :update, :destroy ]
|
||||
before_action :set_link_token, only: :new
|
||||
|
|
14
app/controllers/concerns/periodable.rb
Normal file
14
app/controllers/concerns/periodable.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
module Periodable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :set_period
|
||||
end
|
||||
|
||||
private
|
||||
def set_period
|
||||
@period = Period.from_key(params[:period] || Current.user&.default_period)
|
||||
rescue Period::InvalidKeyError
|
||||
@period = Period.last_30_days
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue