Skip to content

Is there a way to add flash messages to a page? #48

Open

Description

@pboling

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.

Activity

  1. pboling commented on May 1, 2024

    @pboling
    Author

    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.

  2. pboling commented on May 13, 2024

    @pboling
    Author

    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?

  3. pboling commented on May 13, 2024

    @pboling
    Author

    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
    
  4. blocknotes commented on Jun 10, 2024

    @blocknotes
    Owner

    Thanks for your feedback @pboling - I'll make some evaluations when possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions