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

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

Open
backward-crazy-mage-puppy-36 opened this issue Jul 30, 2022 · 0 comments

Comments

@backward-crazy-mage-puppy-36
Copy link

backward-crazy-mage-puppy-36 commented Jul 30, 2022

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.

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

1 participant