== README
This is intended to reproduce https://github.com/rails-api/active_model_serializers/issues/208
You'll also need to grab https://github.com/steveklabnik/blorgh
Finally, you'll need to change Gemfile references in both the app and the engine to point at your own copy of rails and blorgh, rather than mine.
=== The issue
Basically,
def utt_url
app.routes.url_helpers.root_path
#Blorgh::Engine.routes.url_helpers.root_path
end
This doesn't work. Flip the comments, and it does. This is a bug.
You can find this code in the Blorgh repo, app/serializers/blorgh_serializer.rb
You can get an entry by spinning up a server,
$ bin/rails s
hitting the right page
$ open http://localhost:3000/blog/posts/new
Filling out the form, then hitting create. It should redirect you to
http://localhost:3000/blog/posts/1
Which should give you the serialized json.
If I make a change to Rails:
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 5379547..831c007 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -43,8 +43,9 @@ module ActionController options.relative_url_root ||= app.config.relative_url_root
ActiveSupport.on_load(:action_controller) do
-
include app.routes.mounted_helpers
-
include AbstractController::UrlFor extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
-
include app.routes.mounted_helpers extend ::ActionController::Railties::Helpers options.each do |k,v|
It still doesn't actually fix things. Drat.