Git Product home page Git Product logo

rack-flash's Issues

undefined method '<<' for nil:NilClass

It does not seem to be working with Sinatra 1.3.2

When just requiring rack-flash it throws this error:

ERROR NoMethodError: undefined method `<<' for nil:NilClass
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/rack-flash-0.1.2/lib/rack/flash.rb:11:in `use'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1339:in `setup_default_middleware'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1327:in `build'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1321:in `new'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1311:in `prototype'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `block in call'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in `synchronize'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `call'
    /Users/david/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/handler/webrick.rb:59:in `service'
    /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Sinatra Multiple Files error

Hi I've just been developing an app in sinatra and just moved my authentication logic to another file, but when i tried to use flash[:notice] from inside that file it is nil al the way. It still works fine for the main file though. It's weird. I just installed sinatra-flash to check if it was me, but this works fine.

Thnx

flash[:notice] unset after a redirect

Hi,

In my sinatra app, I would like to be able to set a flash[:notice] message, then redirect, but it seems that the flash[:notice] is empty after a redirect.

Is this the expected behaviour?

Thanks,
Steven

Use rack-flash with sinatra test environment

I'm developing a Sinatra application using cucumber.

In my env.rb cucumber configuration file, I have specified:

set :environment, :test

This gives me an error:

Rack::Flash::SessionUnavailable - Rack::Flash depends on session middleware

If you could tell me what's causing that, or how to get round it - would be much appreciated.

Am using:
cucumber (0.4.4)
rack (1.0.1)
rack-flash (0.1.1)
rack-test (0.5.3)
sinatra (0.9.4)

Thanks,
Steven

Can't check for empty flash

I've been looking for a simple way to check if the flash is empty, but it does not provide any simple array/hash methods for that.

Maybe adding an empty? method to the class that returns true on empty values.

Any ideas on how to do that right now?

Doesn't work with JSON session cookies

Flash keys are automatically converted to symbols. However symbols are not supported by JSON session cookies.

require 'sinatra/base'
require 'rack/flash'

class Server < Sinatra::Application
    configure do
        use Rack::Session::Cookie, coder: Rack::Session::Cookie::Base64::JSON.new
        use Rack::Flash 
    end

    get '/' do
        flash['foo'] = 'bar'
    end
end

Server.run!

Running this sample code produces the error:

Rack::Utils::OkJson::Error at /
Hash key is not a string: :foo

Better doc for tests

A minimal note on Readme file to test the flash value would be great.
I found this way works for me (minitest, rack-test)

assert_equal 'my message', last_request.env['x-rack.flash'][:alert]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.