soveran / cuba

Rum based microframework for web development.
http://cuba.is
MIT License
1.44k stars 249 forks source link

undefined method `DelegateClass' for Rack::Session::Cookie:Class (NoMethodError) #98

Closed tablecell closed 4 years ago

tablecell commented 4 years ago

/Ruby27/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/session/cookie.rb:155:in <class:Cookie>': undefined methodDelegateClass' for Rack::Session::Cookie:Class (NoMethodError) hele_world.rb

require "cuba"
require "cuba/safe"

Cuba.use Rack::Session::Cookie, :secret => "__a_very_long_string__"

Cuba.plugin Cuba::Safe

Cuba.define do
  on get do
    on "hello" do
      res.write "Hello world!"
    end

    on root do
      res.redirect "/hello"
    end
  end
end
soveran commented 4 years ago

@tablecell Thanks for reporting this issue. It looks like it's a known bug in Rack: https://github.com/rack/rack/pull/1610

I added a workaround and pushed the version 3.9.3.

tablecell commented 4 years ago

btw

on "username/:username" do |username|
      user = User.find_by_username(username) # username == "foobar"

Is "User" extends from ApplicationRecord ? Is there any crud example code for database ,such as blog post /list

soveran commented 4 years ago

I think it should work just fine with ActiveRecord or any other ORM. Can you give it a try and tell me how it goes?