Skip to content

Getting Error: FrozenError: can't modify frozen String when using with roda-sequel-stack #1

@backward-crazy-mage-puppy-36

Description

Hi,

I have cloned https://github.com/jeremyevans/roda-sequel-stack
and added roda_controller.rb at project root with the following code:

roda_controller.rb

class RodaController
attr_reader :request, :response

def initialize(request, response)
@request = request
@response = response
end

def respond_with(opts)
@responds_with ||= {}
@responds_with.merge!(opts)
end

def self.descendants
ObjectSpace.each_object(Class).select { |klass| klass < self }
end
end

I have also created a ./controllers/users_controller.rb with the following code:

class UsersController < RodaController
def index
"User Index"
end

def show(user_id)
"User Show ##{user_id}"
end
end

I have added to my app.rb:

configuring the plugin

plugin :controller, inject: ->{ [request, response] }

Dir["controllers/*.rb"].each { |file| require_relative file }

RodaController.descendants.each do |controller|
controller_key = Roda::RodaPlugins::Controller.underscore(controller.name)
controller_proc = -> (req, res) { controller.new(req, res) }

register_controller(controller_key, controller_proc)
end

When starting 'rackup' I get:
Error: FrozenError: can't modify frozen String: "UsersController"

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions