Hi,
I am trying to create routes at runtime but I am finding this a but of a
challenge. I can get it to register as a route using the code below but
then when url_for( with_url_options ) is called it throws an on any
different fout error:
No route matches {:action=>“index”,
:controller=>“admin/scientific_review_processes__1__1s”
When I try to load a different meta model/controller/route I have to
stop/start the server and it will work. I want to be able to load and
unload controllers/models and routes at runtime but I have yet to make
this
work correctly.
private
def create_route(table_name)
# if
Rails.application.routes.named_routes.routes[“admin_#{table_name}”.to_sym].nil?
Rails.application.routes.disable_clear_and_finalize = true
Rails.application.routes.draw do
namespace :admin do
resources table_name.to_sym do as_routes end
end
end
#binding.pry
#Rails.application.routes.finalize!
# ActiveSupport.on_load(:action_controller)
{Rails.application.routes.finalize! }
# end
end
Does anyone know what would make such a thing work in a runtime
environment?
Thanks in advance,
Mark