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

Session is cleared after each request #64

Closed
lessless opened this issue Dec 15, 2014 · 4 comments
Closed

Session is cleared after each request #64

lessless opened this issue Dec 15, 2014 · 4 comments

Comments

@lessless
Copy link
Contributor

Hello! I faced an error using flash: undefined method `[]' for nil:NilClass and it looks like a bug. Further investigation showed that session is cleared after each request in the Lotus::Action::Callable#finish and thus it's no wonder that here is no "__flash" key in the session hash.

/Users/lessless/.gem/ruby/2.1.5/bundler/gems/controller-975feb8788de/lib/lotus/action/flash.rb:127:in `remove!'
/Users/lessless/.gem/ruby/2.1.5/bundler/gems/controller-975feb8788de/lib/lotus/action/flash.rb:65:in `clear'
/Users/lessless/.gem/ruby/2.1.5/bundler/gems/controller-975feb8788de/lib/lotus/action/session.rb:143:in `finish'
/Users/lessless/.gem/ruby/2.1.5/bundler/gems/controller-975feb8788de/lib/lotus/action/callable.rb:89:in `finish'
@jodosha jodosha added the bug label Dec 15, 2014
@gogogarrett
Copy link

Can you post an example of the code you're using to cause this error?

@runlevel5
Copy link
Member

@lessless
Copy link
Contributor Author

it's something like this

module App
  class Application < Lotus::Application
    configure do
      layout :application
      load_paths << 'app'
      routes 'config/routes'
      default_format :json

      sessions :cookie, secret: 'mysecret'
      controller.prepare do
        expose :flash
      end
    end

    def self.root
      Pathname.new(File.expand_path(__dir__, '../..')).dirname.realpath
    end

  end
end


module App::Controllers::Submissions
  include App::Controller

  class Create
    include App::Action

    def call(params)
       flash[:success] = "OK!"
      redirect_to params.env["HTTP_REFERER"]
    end
  end
end

@jodosha
Copy link
Member

jodosha commented Dec 20, 2014

Closing in favor of hanami/hanami#110

@jodosha jodosha closed this as completed Dec 20, 2014
@jodosha jodosha removed the bug label Dec 20, 2014
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