Ruby on Rails
Thursday, December 10, 2015
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
-- 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
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1b16952a-c4b8-4d3f-a6fa-206aae71292a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment