mirror of
https://github.com/we-promise/sure.git
synced 2026-09-02 05:11:05 +00:00
* fix(accounts): remember transaction page size across account navigation per_page was only ever read from the current request's query string, so switching accounts always reset the activity feed back to 10 entries. Reuses TransactionsController's existing prev_transaction_page_params session store so the chosen page size applies consistently on both the account detail page and the global transactions page. Closes #3082 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(accounts): validate stored per_page and preserve it across filtered requests Addresses review feedback on #3084: safe_per_page now validates the stored default against the allowed values (a raw stored value like "1" was previously passed through unchecked), TransactionsController no longer wipes the remembered per_page when a request supplies filters but omits per_page, and Session#prev_transaction_page_params normalizes a NULL value to an empty hash. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(transactions): use stored per_page as pagy fallback on filtered requests store_params! already preserved the previously-selected per_page in the session when a filtered request (e.g. dashboard money-flow links) omitted it, but TransactionsController#index still called safe_per_page with its hardcoded default of 10, so the stored preference was never applied to the actual page rendered. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Gerald <248542187+gfr-free@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
40 lines
909 B
Ruby
40 lines
909 B
Ruby
class Session < ApplicationRecord
|
|
include Encryptable
|
|
|
|
# Encrypt user_agent if ActiveRecord encryption is configured
|
|
if encryption_ready?
|
|
encrypts :user_agent
|
|
end
|
|
|
|
belongs_to :user
|
|
belongs_to :active_impersonator_session,
|
|
-> { where(status: :in_progress) },
|
|
class_name: "ImpersonationSession",
|
|
optional: true
|
|
|
|
before_create :capture_session_info
|
|
|
|
def prev_transaction_page_params
|
|
super || {}
|
|
end
|
|
|
|
def get_preferred_tab(tab_key)
|
|
data.dig("tab_preferences", tab_key)
|
|
end
|
|
|
|
def set_preferred_tab(tab_key, tab_value)
|
|
data["tab_preferences"] ||= {}
|
|
data["tab_preferences"][tab_key] = tab_value
|
|
save!
|
|
end
|
|
|
|
private
|
|
|
|
def capture_session_info
|
|
self.user_agent = Current.user_agent
|
|
raw_ip = Current.ip_address
|
|
self.ip_address = raw_ip
|
|
self.ip_address_digest = Digest::SHA256.hexdigest(raw_ip.to_s) if raw_ip.present?
|
|
end
|
|
end
|