Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit documentation that "Flash" word is a reserved key for Action layer #595

Closed
rafaels88 opened this issue Jun 6, 2016 · 6 comments

Comments

@rafaels88
Copy link

This is just a request to put this information in documentation.

I was trying to create a simple system for flash message using session + shared code, and no errors occured, but exposed :flash attribute always had {} as value.

Steps to reproduce

# apps/web/controllers/flash.rb
module Web
  module Flash
    after :flash!
    expose :flash

   private

   def flash!
     @flash = {}

     if session[:flash_message]
        @flash[:success] = session[:flash_message]
        session[:flash_message] = nil
    end
  end
end
# index.html.erb
<%= flash[:success] %>

Actual behavior

Rendering result will always be {}.

Expected behavior

Should be == session[:flash_message].

I figured that Flash is a kind of internal module for Hanami Controller, so this issue is just a request for this to be documented.

@cllns
Copy link
Member

cllns commented Jun 6, 2016

Thanks! Good find. Indeed flash is used in Hanami::Action::Session.

Personally, I'd rather see an error telling the developer that flash is reserved (and links to docs about flash) rather than just document it.

What do others think about that? If that's desired, this should be filed in in hanami/controller.

@b264
Copy link

b264 commented Jun 6, 2016

👍 for raise telling developer flash is reserved

@rafaels88
Copy link
Author

👍 for raise.

@jodosha
Copy link
Member

jodosha commented Jun 8, 2016

Yes, this should go in hanami-controller.

@cllns
Copy link
Member

cllns commented Jun 8, 2016

We can close this, in favor of this Issue in hanami-controller: hanami/controller#158

@jodosha
Copy link
Member

jodosha commented Jun 15, 2016

@cllns Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants