Open pboling opened 4 months ago
In other words, I think there is a bug, or missing documentation. I've tried everything I can think of and I can't get them to render.
So far I have tried setting flash via:
rodauth.flash[:error]
rodauth.flash.now[:error]
And a bunch of other crazy things...
I think the issue is that I am expected to send the alerts / flashes in to the prepare_page
call somehow. This doesn't make any sense to me since it should have access to the rodauth.flash
.
@blocknotes any idea how to use flash?
I have gotten it to work, but it doesn't seem to be the intended way to do it.
become_action_page.rb
(simplified example)
module Admin
class BecomeActionPage < TinyAdmin::Views::DefaultLayout
attr_accessor :alerts
def view_template
@messages = alerts
super do
# ... etc
become_action.rb
(simplified example)
module Admin
class BecomeAction < TinyAdmin::Actions::BasicAction
def call(app:, context:, options:)
id = context.reference.to_i
account = Account.find(id)
r = context.request
rodauth = r.env["rodauth"]
notices = ["You are now #{account[:email]}"]
alerts = {notices:}
rodauth.become_account(account)
prepare_page(
Admin::BecomeActionPage,
attributes: {
email: account[:email],
alerts:,
},
)
# ... etc
Thanks for your feedback @pboling - I'll make some evaluations when possible.
I haven't been able to figure it out, and there are no examples in the documentation or specs.
I'm reading through the source, but it isn't clear how the various Flash mentions are connected.